TypeOrm how to get Items with multiple categories (Filter)

Viewed 72

im trying to use the find options or queryBuilder to get products that have for example the tag "Environment" and "Art"

how can i achieve that? My many to many relation between items and categories is many to many

    @Property()
    @ManyToMany(
        () => Tag
    )
    @JoinTable({
        name: "Product_Tag",
        joinColumn: {
            name: "products",
            referencedColumnName: "id"
        },
        inverseJoinColumn: {
            name: "tag_id",
            referencedColumnName: "id"
        }
    })
    tags: Tag[];

i want to be able to get the items with tag.name = "art" and "environment",Or more

The following didn't work for me

 query.where("tags.name IN(:...cat)", { cat: ["Environment", "Art"] })

Thanks!

0 Answers
Related