Document match
and other populate()
options as options to Schema#virtual()
and VirtualType
constructor
#8616
Labels
docs
This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone
Do you want to request a feature or report a bug?
Feature
Code snippet for use in explanations
Model.populate({ path: 'items', match: { status: 'purchased' }, as: 'purchased_items' }).populate({ path: 'items', as: 'all_items' })
What is the current behavior?
Using the above code snippet, the 'as' is ignored, and the last populate overrides the previous one, resulting in all items being returned under the name 'items'.
What is the expected behavior?
By providing the 'as' property, each populate is returned under its defined 'as' value, items with the status of 'purchased' under the property 'purchased_items' and all items under the property 'all_items'. This ideally would also work with virtual populate, allowing also count operations to be separable.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: 10.16.0
Mongoose: 5.8.4
Mongodb: 3.4.1
The text was updated successfully, but these errors were encountered: