I'm trying to do a custom query in my app built with payload. In this query I filter my Orders collection using the Warehouse collection that are related. I'm trying this way but I can't do it
const orders = await payload.find({
collection: 'orders',
where: {warehouse: {equals: "640a22cacc1ca5ce8e415958"}},
page: page,
});
@here
Hey @Iván Dominguez (Domi) - looks like you're on the right path here, are you getting an error when you run this payload.find?
Also, is your snippet above wrapped with an async function?
e.g.
const getOrders = async () => {
const orders = await payload.find({
collection: 'orders',
where: {...},
});
return orders;
}
Hey @jesschow
yes, this is an async function, but it returns an empty array
@Iván Dominguez (Domi) on your
orderscollection, is
warehousea relationship field to another collection?
and is your access control on the
orderscollection set to true?
What configuration in access control should I set?
read: () => true
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.