Answer the question
In order to leave comments, you need to log in
How to set up interaction between posts and categories (Mongodb, Node.js)?
The project has entities that can be conditionally called posts, and there are entities that can be called categories. For example, a post is a music album. And there are categories - 'artist', 'label' and 'genre'. An album can be assigned to multiple artists, multiple labels, and multiple genres. For example, when creating a post in album.Schema, I use a field like this:
artists: [
{
type: Schema.Types.ObjectId,
ref: 'artists',
required: true
},
],
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question