Query where clause with array.

How can I get something like this to work?
const products = ["subscription", "insurance"]

const productsToLink = await tx.query.products.findMany({
where: (products, { eq }) => eq(products.name, products),
});
const products = ["subscription", "insurance"]

const productsToLink = await tx.query.products.findMany({
where: (products, { eq }) => eq(products.name, products),
});
I want the where clause to match any product that has a name thats inside the products array.
2 Replies
Ahmed
Ahmed17mo ago
Use inArray
const products = ["subscription", "insurance"]

const productsToLink = await tx.query.products.findMany({
where:inArray(products.name,
products),
});
const products = ["subscription", "insurance"]

const productsToLink = await tx.query.products.findMany({
where:inArray(products.name,
products),
});
Nickolaki
NickolakiOP17mo ago
Perfect thank you, just seen all the possible operators on the docs. ❤️
Want results from more Discord servers?
Add your server