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
Is it possible to populate without _id
?
#2562
Comments
It would be great to be able to customize this, but right now we enforce |
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). |
@taxilian are you setting the |
I haven't actually moved to start doing it yet because I've been looking for a solution to this issue; does populate take into account shardKey? My understanding was that shardKey only affected updates and inserts |
It would be great to be able to specify the field which is to be "joined by", for example I'd like to be able to populate not only by userId (i.e. _id) field but also by userType, userGroup etc. |
+1 |
+1 would be very useful |
+1 same here! |
+1 love to have this |
+1 |
1 similar comment
+1 |
+1 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 |
+1 |
6 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
Big agree. I'd love the ability to define custom population schemes. It'd be great for any schema with one or more fields that are file paths, allowing populate to read from storage. |
+1 |
8 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
10 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
Expose mongoose-populate-virtuals API in core
+1 |
+1 |
+1 |
+1 |
2 similar comments
+1 |
+1 |
+3 |
+1 |
I checked the API http://mongoosejs.com/docs/populate.html and tried out. It seems that
populate
can only works on foreign_id
. Even there is amatch
option, it just add more filtering condition on_id
query condition. There is no way to just populate with fields not involved with_id
.In my project, we keep the
_id
as ObjectId and has another field as auto-increment Number. For example,customers
model has_id
as Object andcuid
as incremental number. Other collections just reference tocuid
not to_id
.Is would be great to be able to customize this?
Is there any design limitation causing this feature missing?
The text was updated successfully, but these errors were encountered: