-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add draft
argument to count operation
#9483
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is right. The draft
arg in other operations only controls whether or not the latest version fetch should include drafts or not. With that, the number of docs should not change based on this flag because even a document that only had _status: 'draft'
is still returned in a find
.
I think the purpose of what you're trying to do here is to expose db.countVersions
through the count
operation. Instead this should be done using:
;({ totalDocs: unpublishedVersionCount } = await payload.countVersions({
collection: collectionConfig.slug,
user,
where: {
and: [
{
parent: {
equals: id,
},
},
{
'version._status': {
equals: 'draft',
},
},
],
},
}))
I guess the args could matter if you need them for querying. I can see how the |
@DanRibbens the logic for Payload side: payload/packages/payload/src/collections/operations/find.ts Lines 143 to 165 in cae300e
Database adapter: payload/packages/drizzle/src/queryDrafts.ts Lines 10 to 31 in cae300e
So, to transition from
I don't think So really we just instead of the original table, query latest documents from the versions table which may include drafts. |
Allows to count drafts in count operation (both Local and REST) via
draft: true
.Additionally, passes the
locale
argument todb.count
/db.countVersions
/db.countGlobalVersions
as the database adapter may use it for querying.