-
Notifications
You must be signed in to change notification settings - Fork 72
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
How to use Fields parameter with Mongoose paginate #37
Comments
I am having the exact same issue with version 7.0.0 |
We have the same problem, quick fix is to do
This way it is excluded, but is ugly as hell |
Also a bad idea above, the _id field will disappear |
it seems this is caused by a bug; mongoist API's findAsCursor method uses projection as second param see docs where as official mongodb driver uses options object as second param see docs
|
I'm having the same issue. I'm using the workaround above but re-including the id: List.paginate({
fields: {
_id: 1,
fields: {
other: 1,
items: 1
}
}
}) |
A slight modification of this worked for me. List.paginate({
fields: {
_id: 1,
projection: { other: 1, items: 1 }
}
}); Mentioning only projection property will strip of the _id property. If you do want the _id property, above workaround worked good for me. The fix for the above issue is raised in the PR #357. But because of this issue (#361), I think PR is not getting approved and merged. Hope this is fixed sooner |
Current Behaviour
The following fields parameter in my Mongoose query is not recognised by paginate function since the query simply returns the entire result including "bids.bid", which I am explicitly excluding. It appears any fields I include are disregarded.
Additionally, whenever I include a "fields" parameter in the paginate function, the _id is also never returned; however, removing the "fields" parameter entirely brings back the _id field as expected.
Expected Behaviour
The documentation for the paginate function refers to the find section so I was expecting the "fields" parameter to work as it does when not using Mongoose.
How should I exclude/include certain fields from my query using Mongoose and paginate?
The text was updated successfully, but these errors were encountered: