These are chat archives for Automattic/mongoose

13th
May 2018
Arun Gadag
@arun-awnics
May 13 2018 12:19
Right. After going through the documentation, it is evident that Mongo discourages your second approach just because to reduce the number of queries and the way data is stored and fetched.
They have advised to reduced the number of normalized data models we use. As you pointed me out, I was wrong thinking the second approach will be right. I realize that is only in the case of RDBMS and mongo is non-relational DB
Thank you @ehsansh
Kev
@lineus
May 13 2018 12:36
I think in the context of purchases @arun-awnics, you were right the first time. Documents in mongodb have a 16MB hard limit. Imagine if amazon used mongodb to store a user's purchases in an array of embedded docs. After roughly 10 years of saved purchase info, I'm pretty sure my user would be broken on Amazon, or they'd have to jump through some serious hoops to store all of my historical info. It makes more sense to me to have a purchases collection with a field in the docs that points back to the user.
Arun Gadag
@arun-awnics
May 13 2018 12:40
Wow. I didn't see that coming @lineus You are right. It all depends on the storage data though. He is gonna store string value in that document. If at all it can fill up 16MB of storage space, then it is a good idea for him to separate it out, else he can still go ahead and store it in the same document.
@ehsansh You can consider @lineus 's point of view on this.
Ehsan Shadmehri
@ehsansh
May 13 2018 20:18
@lineus @arun-awnics Thanks
Imagine a subscription website that user after purchase has access to the limited number of articles. I should store id of each article. Maybe hundreds of articles with their ids needed to be stored. What is the best approach? Store them in an array of a purchase document? Is is good despite the limit storage space?
Each document has a _id which contains many characters. Is it good approach to store these idis becasue they need much space?!
Ehsan Shadmehri
@ehsansh
May 13 2018 20:23
Another question mongodb has schema validation in its core: https://docs.mongodb.com/manual/core/schema-validation/ So why should we use mongoose?
While mongodb is schema-less why should we use mongoose. Why not using sql database?