For collection level access, you can limit which users can read or provide a where query to allow only specific documents to be read. I'd like to keep public read access to the entire collection, but provide a where query for the documents that show up in the admin panel for the collection. Specifically, I want to be able to limit the documents based on a field on the user and document, kind of like a filterOptions from a relationship field but for the admin panel's documents (not overall collection reads). Is there a way to do this?
you can do this with JS if statements 🤦♂️ just filter when the user is signed in and return
true
for whatever web client you're using.
if (user && user.role === "user") {
return {
id: { equals: user.company.id },
};
}
if (user && user.role === "admin") {
return true;
}
return true;
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.