Please tell me if this is an appropriate solution to my problem:
As a manager of a franchise, you can log in. There's a list of all your employees. On the left it says:
Company Name
Store 1
- Section 1
- Section 2
Store 2
- Section 1
- Section 2
So here's an example
Bob's Grocery Stores
Chicago Store
- Deli
- Vegetables
- Checkout
New York Store
- Bakery
- Deli
- Vegetables
- Checkout
So currently my idea is to have 2 models. A user model and a company model. I'm using a second company model because if the store name changes with one user, it needs to change with every user. Then I user a ref to that company within the user document.
var CompanySchema = new Schema({
name: {
type: String,
},
store: {
type: Array
},
});
I would have the sections inside the 'store' property because different stores have different sections.
So far I think everything is correct. My question is how do I assign a user to a specific section in a store. Would it be user.company.store[3].section[1]? Wouldn't the indexOf values for section/store change if a section/store get deleted? How do people generally go about doing something like this? I'm basically creating the same thing as folder/file directory.