Answer the question
In order to leave comments, you need to log in
Is it possible to perform such operations in Mongo?
Good afternoon, there are restaurants and categories. When adding a restaurant, the necessary categories are selected.
That is, the fields for the restaurant in this form
categories: [ { type: mongoose.Types.ObjectId, ref: "Category" } ]
const CategorySchema = new mongoose.Schema({
name: { type: String, required: true, unique: true },
slug: { type: String, required: true, unique: true },
restaurants: [{ type: mongoose.Types.ObjectId , ref: "Restaurant" }]
})
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