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

observeOptions does nothing / can't use limit and skip #51

Closed
onlysli opened this issue Jan 16, 2019 · 2 comments
Closed

observeOptions does nothing / can't use limit and skip #51

onlysli opened this issue Jan 16, 2019 · 2 comments

Comments

@onlysli
Copy link

onlysli commented Jan 16, 2019

Hello,
The documentation says that I can use 'limit' like this:

observeOptions: {
        limit: 10,
        skip: 0,
        sort: { createdAt: -1 },
}

It does not work, i always get all the documents that corresponds to the query.

Also, i tried adding limit directly in the pipeline:

{
      $lookup: {
        from: 'users',
        localField: 'userId',
        foreignField: '_id',
        as: 'user'
     }
}, 
{
      $project: _adsPublicFields
}, 
{
      $limit: 10
},
{
      $skip: 0
}, 
{
      $sort:  { createdAt: -1 },
}

This works only if skip is 0, if skip is 10, it will retun empty, if skip is 6, it will return 4 results (the limit 10 - skip 6).

What can i do to make it work?

@jbx-alex
Copy link

jbx-alex commented Jun 5, 2019

Hello @onlysli,

I have had the same problem, I am using this library https://github.com/robfallows/tunguska-reactive-aggregate (it's a reworks of jcbernack:reactive-aggregate for ES6/ES7 and Promises) and it seems that this is because of the order of the parameters, try to put it like this:

{
    $sort:  { createdAt: -1 }
},
{
    $limit: 10  
}, 
{
    $skip: 0
}

I add the link of my example robfallows/tunguska-reactive-aggregate#12

Regards.

@JcBernack
Copy link
Owner

Closing old issues.

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

3 participants