I added drafts to my pageType collection, however afterwards the pages I already made in this collection didn't show anymore in the admin/collection/pageType. Below is my code I added. Does anyone know If I'm missing something?
access: {
read: () => {
if (isLoggedIn) {
return true;
}
return {
or: [
{
_status: {
equals: 'published',
},
},
{
_status: {
exists: false,
},
},
],
};
},
},
versions: {
drafts: true,
},
What happens is the list is populated from querying from _collectionname_versions, a separate collection from the main when versions are enabled. To fix it, every document that existed before versions was enabled needs to be resaved.
There is a script in the changelog that resaves all documents in a collection. It could also be done using a PATCH request for the entire collection.
PATCH
/api/pageType?where[id][exists]=true
body: {_status: 'draft'}
headers: {
content-type: application/json
authorization: JWT TOKENFROMCOOKIE
}
Sorry for the psuedocode, I'm on mobile. I hope this gives you an idea on what to do.
This is something we need to document better.
Cool! Thanks for the quick response!
Hey, just asking if adding _status solves your issue; I tried adding this directly to the database and the problem persists 😢
Can you share the script for resave all documents in a collection, please?
btw, thanks for the PATCH example, works well!
Apologies for the late response. If it's still relevavant to you, adding _status wasn't the way to go, but instead running the migrateVersions script available on payloads github repo.
thx for the reply 🫡 problem solved
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.