Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Replaced deprecated count() method #153

wants to merge 1 commit into from

Conversation

achere
Copy link

@achere achere commented Dec 18, 2018

No description provided.

@@ -51,7 +51,7 @@ function paginate(query, options, callback) {
}
promises = {
docs: docsQuery.exec(),
count: this.count(query).exec()
Copy link

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,
Copy link

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;
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants