mongo-cursor-pagination icon indicating copy to clipboard operation
mongo-cursor-pagination copied to clipboard

Fields projection not working on .find method

Open XxStunner opened this issue 3 years ago • 1 comments

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 });

XxStunner avatar Nov 26 '21 14:11 XxStunner

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

bradvogel avatar Nov 30 '21 19:11 bradvogel