Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Is it possible to populate without `_id` ? #2562
I checked the API http://mongoosejs.com/docs/populate.html and tried out. It seems that
In my project, we keep the
Is would be great to be able to customize this?
The ability to populate not just on a single other field but even on a set of fields is almost required to properly support sharding, which is a huge use case for us.
For example, we have a collection "students" which may have a shard key for "subscription"; when we populate student data from our sections model (which contains an array of students) we have the subscription on the document but it will only look up based on the _id stored in "student" rather than allowing us to specify that it should also map the documents "assignment" field to "assignment" on the student.
Since we'd then be doing a lookup without the shard key when doing populate it renders sharding useless, requiring all shards to be hit to retrieve the data instead of just one.
This is something we would be willing to fund development for or even do ourselves if we could get some guidance of where to do the work. It is a major need for our company (GradeCam).
It would be especially nice to be able to select the variable you would like to populate with by adding a parameter such as
For example if had posts that I wanted to populate the
It would be nice to be able to add a parameter like "key" to let mongo know which parameter to lookup by:
This would fill the