Answer the question
In order to leave comments, you need to log in
Links between documents in MongoDB. How to remove pointers?
There are two documents Price and Product.
Their simplified structure:
Price = {
name: String,
id: ObjectId,
products; [ ObjectID ] // Массив с id товаров которые есть в этом каталоге
}
Product = {
name: String,
id: ObjectId,
relationToPrice: ObjectId // Указатель на документ Price к которому относится товар
}
Answer the question
In order to leave comments, you need to log in
Why did you separate them? An array with catalog id's could be put into a product, it's not a muscle, after all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question