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

_getQueryModifier not applied on service _find with pagination #421

Open
arkabase opened this issue Dec 1, 2021 · 0 comments
Open

_getQueryModifier not applied on service _find with pagination #421

arkabase opened this issue Dec 1, 2021 · 0 comments

Comments

@arkabase
Copy link

arkabase commented Dec 1, 2021

In service.js (line 104) method _getQueryModifier is applied to mongoose query q :
this._getQueryModifier(params)(q, params);

but when pagination is active (lines 124+), a new query is used to count the documents instead of q :

if (paginate && paginate.default) {
      return model.where(query)[this.useEstimatedDocumentCount ? 'estimatedDocumentCount' : 'countDocuments']()
        .session(params.mongoose && params.mongoose.session).exec().then(executeQuery);
}

_getQueryModifier is not applied to this new query, and so the total can be false if the queryModifier function filters the original query.

This part should be :

if (paginate && paginate.default) {
      const w = model.where(query);
      this._getQueryModifier(params)(w, params);
      return w[this.useEstimatedDocumentCount ? 'estimatedDocumentCount' : 'countDocuments']()
        .session(params.mongoose && params.mongoose.session).exec().then(executeQuery);
}
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

No branches or pull requests

1 participant