MongoDB design schema for database with users and roles

sarakinos Source

i'm trying to come up with a database design in mongo ( fairly new to this world ).

My database will be something like that

Users

{
 name,
 surname,
 password,
 role, *Enum
 shop : {
   products
 }
}

Consider the user as the top level entity. The above example tries to blueprint a user how has many shops and each shop can have many products. My main problem is when the roles come in play. Lets say i want to create a manager, who can interact with one of the Users shops. The manager has to be a user so he can login and has to have an "owner" ?(the user) and a shop attached to him?

I'm confused about how to design it so every hint is appreciated. Thanks in advance

databasemongodbnosql

Answers

comments powered by Disqus