0

I am new to node and practicing it...

I have a requirement where user will have a profile section Where he fills lot of data like his educational details , employment details , address , and many other details.

As of now I am creating user collection on signup.

Can I maintain the a separate collection for profile details and whenever user details updated I will update initial registered collection also

Is this a good approach or do I need to maintain only one collection.

Can some one suggest me which is the best

1
  • If you would need to access or update the information from both collections in a single transaction, then generally you might want to lean towards having just a single user collection. May 9, 2021 at 8:57

2 Answers 2

0

it is not uncommon to have more than 1 or more user collection, for at the very least, passwords should not be in the same collection of other public data.

You could also end up with different user collection of

  • personal data
  • sensitive data
  • browsing history

etc. All referenced by the same user _id

Data however, should in the best scenario, not be overlapped. Hence so there should only a single source of truth of value, except for _id which is used for referencing.

If you update a value in one collection, you should not need to update same value in another colletion.

0
0

I think you can have a single user collection with other info like educational details in it.

In mongo, there is no use in having a different collection and maintain the relationship between them. Your queries will be a little bit expensive if you store the data in a different collection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.