Title basically 🙂
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",
},
},
});
thanks
-> only return published and in with specific where
hey @banks , 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-logicthanks, I appreciate it
Star
Discord
online
Get dedicated engineering support directly from the Payload team..