T
T
Test Test2015-10-14 20:32:02
MongoDB
Test Test, 2015-10-14 20:32:02

What is the best way to organize a MongoDB database (using Mongoose)?

Hello! I have this question: how best to organize a database on MongoDB (Mongoose):
Let's say we have two entities: User (user) and UserProfile (user profile).
How best:
1. Divide User and UserProfile into two models
2. Do everything in one model, make something like this scheme:

{
username: {},
profile: {
   firstName: {},
   lastName: {}
}
}

Maybe this is not the best example, but still, could you tell me which approach is better? I assume 2, but not in all cases.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2015-10-14
@cubooks

And why an extra level of nesting, what is the point of storing them separately.
In my life I came across both cases in both cases I wanted to shove rebar in the ass to programmers like you.
Make just one table with three fields without any idiotic nesting and different entities.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question