mongo-cursor-pagination
mongo-cursor-pagination copied to clipboard
Allow user to restrict fields to return when using mongoose
By default, queries in MongoDB return all fields in matching documents. To limit the amount of data that MongoDB sends to applications, you can include a projection document to specify or restrict fields to return.
Issue
using params.fields
does nothing and all fields is returned in matching documents.
Expected
it('returns data with expected fields', async () => {
const data = await Post.paginate({ fields: { title: 1 }, limit: 1 });
const [post] = data.results;
expect(post.title).toBeTruthy();
expect(post.date).toBeFalsy();
expect(post.author).toBeFalsy();
expect(post.body).toBeFalsy();
});
The following test failed.
This PR seems to solve the issue : https://github.com/mixmaxhq/mongo-cursor-pagination/pull/60
Please make a review if possible
I am having this issue as well. Did you ever find a solution?
I am having this issue as well. Did you ever find a solution?
Yes, this PR resolves the issue https://github.com/mixmaxhq/mongo-cursor-pagination/pull/239
don't hesitate to review the PR.