-
Notifications
You must be signed in to change notification settings - Fork 216
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
Replaced deprecated count() method #153
base: master
Are you sure you want to change the base?
Conversation
@@ -51,7 +51,7 @@ function paginate(query, options, callback) { | |||
} | |||
promises = { | |||
docs: docsQuery.exec(), | |||
count: this.count(query).exec() |
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.
When using countable querying you should use @estimatedDocumentCount as discussed in: Automattic/mongoose#6713.
@@ -66,15 +66,15 @@ function paginate(query, options, callback) { | |||
return Promise.all(promises).then((data) => { | |||
let result = { | |||
docs: data.docs, | |||
total: data.count, |
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.
This should stay as is (data.count). Because property count is result of @estimatedDocumentCount method.
limit: limit | ||
}; | ||
if (offset !== undefined) { | ||
result.offset = offset; | ||
} | ||
if (page !== undefined) { | ||
result.page = page; | ||
result.pages = Math.ceil(data.count / limit) || 1; |
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.
This should stay as is (data.count). Because property count is result of @estimatedDocumentCount method.
No description provided.