-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Populating with perDocumentLimit multiplies common entries #9906
Comments
@paulholleis When you say that the script works without perDocumentLimit, Do you mean it will run or that it does the expected behavior? |
@IslandRhythms thanks for looking at its! And sorry, that was not well written from my side. I meant to say, without the perDocumentLimit, this test script fails as expected since the resulting "posts" then contain all 4 and 5 "comments" respectively (correctly as single items), e.g.: {"commentsIds":[
{"_id":"6022429a33fbeae353c9f777","content":"Im used in two posts","__v":0},
{"_id":"6022429b33fbeae353c9f779","content":"Cool first post","__v":0},
{"_id":"6022429b33fbeae353c9f77a","content":"Very cool first post","__v":0},
{"_id":"6022429b33fbeae353c9f77b","content":"Super cool first post","__v":0}
],
"_id":"6022429b33fbeae353c9f778","title":"I have 3 comments","__v":0}
If you need a succeeding test for that, just replace the last two assertions with the expected 4 and 5 instead of 2. assert.equal(posts[0].commentsIds.length, 4);
assert.equal(posts[1].commentsIds.length, 5); |
Do you want to request a feature or report a bug?
I think it's a bug with perDocumentLimit.
What is the current behavior?
Have 2 objects of the same Model M with each an array M.arr; both arrays have an entry that ref the same object X.
When populating with perDocumentLimit, I get, instead of just the populated X object, an array [X, X] within M.arr
If the current behavior is a bug, please provide the steps to reproduce.
This is the 9175.js with an added commonComment that is added to both Posts.
The script runs perfectly well without perDocumentLimit.
This produces
What is the expected behavior?
It should include the commonComment only once and not an array of two commonComments.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node: v14.15.1
Mongoose: 5.11.15
MongoDB: v4.2.5
The text was updated successfully, but these errors were encountered: