You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
There is an option named strictQuery in mongoose, that will clean the query from fields that do not exist in the schema.
Say we have a users collection like this:
users { name: String }
Notice that the users schema only has a name property and not an email property, Now if I try:
Users.find({ email: 'something'})
and strictQuery is true for the UserSchema, it will remove the email parameter from the query and the query will become {} so it returns all documents in the Users collection.
if strictQuery is false, it will not clean the query from non-existing fields, so it will return nothing.
Problem is, when strictQuery is sent false to the paginate function, it will truly return noting in docs property, but totalDocs value will not become affected by strictQuery and returns a non-zero value.
To Reproduce
paginate(...., options: { strictQuery: false });
Expected behavior
If there is no value in docs property, totalDocs should be 0 as well. right now, docs and totalDocs are not matched. (not only for 0 value, but it can also be 1 in docs and totalDocs be 3 or something).
Describe the bug
There is an option named
strictQuery
in mongoose, that will clean the query from fields that do not exist in the schema.Say we have a users collection like this:
Notice that the users schema only has a name property and not an email property, Now if I try:
and
strictQuery
istrue
for the UserSchema, it will remove theemail
parameter from the query and the query will become{}
so it returns all documents in the Users collection.if
strictQuery
isfalse
, it will not clean the query from non-existing fields, so it will return nothing.https://mongoosejs.com/docs/guide.html#strictQuery
Problem is, when
strictQuery
is sent false to the paginate function, it will truly return noting indocs
property, buttotalDocs
value will not become affected bystrictQuery
and returns a non-zero value.To Reproduce
Expected behavior
If there is no value in
docs
property,totalDocs
should be 0 as well. right now, docs and totalDocs are not matched. (not only for 0 value, but it can also be 1 in docs and totalDocs be 3 or something).Output Example
The text was updated successfully, but these errors were encountered: