Let us assume the following as the user flow in a multi tenant application with each tenant having its own set of catalogs or share a common catalog.
User logs into the application and see
UI with list of catalogs - User clicks on one catalog and navigates to
UI with list of categories - User clicks on one category and navigates to
UI with list of Groups - User clicks on one group and navigates to
UI with list of Articles - User clicks on one article and navigates to
UI all the details for an Article - an article can be a doc, video or pdf and other metadata
I am new to MondoDB and based on my understanding the document structure could be
[
{
"TenantName": "Tenant A",
"catalogs": [
{
"Categories": [
{
"Groups": [
{
"Articles": [
{
"Article Title": "Title 1"
}
]
}
]
}
]
}
]
},
{
"TenantName": "Tenant B",
"catalogs": [
{
"Categories": [
{
"Groups": [
{
"Articles": [
{
"Article Title": "Title 1"
}
]
}
]
}
]
}
]
}
]
Is the above design the right approach to start with?
But is this performance efficient as I read the root document is performance efficient but the nested may not be. Since the flow of the application is step by step I am worried whether this approach will be helpful considering the performance and the storage.
PS: The category can be part of multiple tenants, same groups can be part of multiple categories, same article can be part of multiple groups
This is how you can use it with mongoose (ORM)
const Article = mongoose.model('Article', ArticleSchema);