FOCUS: One-to-many Relationships
NoSQL databases, unlike SQL databases like PostgreSQL, MYSQL etc, which are traditionally built for ...
For further actions, you may consider blocking this person and/or reporting abuse
Oh, this is a wonderful explanation. Thank you for spending time to make justice to this subject. I was researching ways of handling data modeling effectively in mongoDb and behold I landed In this, and it has cleared the air.
Hi, How can I remove the id and _id repeated from the last image?
link
new Schema({ ... }, { id: false });
is it possible to use mongoose schema post hooks to add relation?
What kind of relationship are you looking to add?
Great article. I am about to implement relations for my MEAN project.
A Couple of questions.
Q-1. Can I have multiple path in find().populate() method?
I have a Log collection, I was thinking to add 4 ObjectId type fields. i.e. client, service, executive, manager - of course apart from its own fields. Each of these are just one object. i.e. One Log entry will be associated with one Client, Service, Execute and Manager.
So I will need to add multiple path with their own select keys. Is that recommended?
And when on frontend, when the Log is displayed, I am planning to populate relevant fields from all these 4 (i.e. Client Name, ClientCategory, ClientSubCategory, ClientRating), (ServiceName, ServiceFreq), ExecName and ManagerName.
The Log display on frontend has Search and filter options on various fields. So when a user searches or applies filters the backend Mongoose query will run again, fetch the data and display.
Q-2: What would be the performance impact if the number of entries in Log collection is in the range to 5000 - 50,000, when I use Child Ref vs Parent Ref? Which one is recommended according to you in this case.
Thanks again
hemant
Great post ....thanks for this.
Question: Please how can i fetch data from db using timestamps. Thanks
This was a good tutorial.Goodjob!👍
Nice write-up! You have done justice to the relationship options available to document-oriented DBs.
Easy to follow too.
Thank you, Kubiat.
Yes this is something clear , at last. It is the backend.
I would like to have the code and adjust it , to my front-end.
Thanks.
Thank you for this wonderfull explanation. Now i can implement my own relations for my express Web App.
Dude it's up to the mark. I just fall in love with your clear explanation. :)
Thank you.
This is very helpful, thank you!