Answer the question
In order to leave comments, you need to log in
What is the best way to store data about objects from another mongodb collection?
There are two collections. In one product and its description, and in another collection, the buyer. I store the basket as an array in the customer. I don't know how better. In the basket to store links (objectid) to goods from the collection of goods or to create the objects themselves in the basket?
Answer the question
In order to leave comments, you need to log in
I think it's better to store links to products, and not copy products - otherwise you can not keep track of information changes, and the user will display outdated information, well, in general,
if this is going to node / mongoose, then I would start with the fact that in the user model made
cart: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Item'
// массив айдишников айтемов из коллекции items
}]
User.findOne({ _id: '......user id ......' }).populate('cart')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question