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

Allow user to restrict fields to return when using mongoose #236

Open
OlivierAlbertini opened this issue Sep 18, 2020 · 2 comments · May be fixed by Gastonite/mongo-cursor-pagination#1
Open

Comments

@OlivierAlbertini
Copy link

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 :
#60

Please make a review if possible

@mark-bt
Copy link

mark-bt commented Sep 25, 2020

I am having this issue as well. Did you ever find a solution?

@OlivierAlbertini
Copy link
Author

OlivierAlbertini commented Sep 25, 2020

I am having this issue as well. Did you ever find a solution?

Yes, this PR resolves the issue #239

don't hesitate to review the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants