Title basically 🙂
thanks
-> only return published and in with specific where
thanks, I appreciate it
Here's an example for a
posts
collection to get only published documents:
const getPosts = async () => {
const posts = await payload.find({
collection: "posts",
where: {
_status: {
equals: "published",
},
},
});
hey
@779076714797334569, sorry for the late reply on this, you can combine multiple query conditions using
and
like so:
where: {
and: [
_status: {
equals: "published",
},
"group.slug": {
equals: slug,
},
],
}
You can also use
or
as well, which works the same way. That would return documents that satisfy
eithercondition, wheras
and
must satisfy both/all conditions.
https://payloadcms.com/docs/queries/overview#and-or-logicStar
Discord
online
Get dedicated engineering support directly from the Payload team.