You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the expected behavior?
Story list have stories [A, B, C]
expect .populate({ options: {skip: 0, limit: 1} }) return A
expect .populate({ options: {skip: 1, limit: 1} }) return B
but .populate({ options: {skip: 1, limit: 1} }) still return A
Please mention your node.js, mongoose and MongoDB version.
Node,js 8, mongoose 5, MongoDB 4
The text was updated successfully, but these errors were encountered:
I took a closer look at this and you need to specify sort here, because MongoDB doesn't guarantee order of query results unless you specify sort, so skip without sort doesn't really make sense. Mongoose does send the correct query and handle the result correctly, it's just that the MongoDB server is returning an incorrect doc unless you explicitly sort.
before('Get first story',async()=>{constlist=awaitStoryList.findById('333333333333333333333333').populate({path: 'stories',options: {skip: 1,limit: 1,sort: {$natural: -1}},});story=list.stories[0];});
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Populate with options,
skip
does not work whensort
not defined.populate({ options: {skip, limit} })
If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/199911/mongoose-populate-bug/blob/master/index.js#L98
What is the expected behavior?
Story list have stories [A, B, C]
expect
.populate({ options: {skip: 0, limit: 1} })
return Aexpect
.populate({ options: {skip: 1, limit: 1} })
return Bbut
.populate({ options: {skip: 1, limit: 1} })
still return APlease mention your node.js, mongoose and MongoDB version.
Node,js 8, mongoose 5, MongoDB 4
The text was updated successfully, but these errors were encountered: