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

Fields projection not working on .find method #313

Open
XxStunner opened this issue Nov 26, 2021 · 1 comment
Open

Fields projection not working on .find method #313

XxStunner opened this issue Nov 26, 2021 · 1 comment

Comments

@XxStunner
Copy link

XxStunner commented Nov 26, 2021

For example, using the code below doesn't work

MongoPaging.find(this.collection, { query, next, limit, paginatedField, fields: { _id: 1, userName: 1, avatar: 1, cover: 1, biography: 1, role: 1, likesCount: 1 }, })

I was able to workaround this issue by adding:

MongoPaging.find(this.collection, { query, next, limit, paginatedField, fields: { projection: { _id: 1, userName: 1, avatar: 1, cover: 1, biography: 1, role: 1, likesCount: 1 } }, })

This should be fixed by changing on line 43 of the find.js to:

const query = collection[findMethod]({ $and: [cursorQuery, params.query] }, { projection: params.fields });

@bradvogel
Copy link
Contributor

Can you demonstrate this bug as a unit test in this codebase and submit a PR? I'm unclear.

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

2 participants