Welcome ... I'm working with Node js and i have a problem Performance Problem Is this code better ... From my point of view the first one not the best because it may takes time for searching about specific item
cart: {
items: [{
productId: {
type: Schema.Types.ObjectId,
ref: 'Product'
},
offerId: {
type: Schema.Types.ObjectId,
ref: 'Offer'
},
quantity: {
type: Number,
required: true
}
}]
}
Or this
product_cart: {
items: [{
productId: {
type: Schema.Types.ObjectId,
ref: 'Product'
},
quantity: {
type: Number,
required: true
}
}]
},
offer_cart: {
items: [{
offerId: {
type: Schema.Types.ObjectId,
ref: 'Offer'
},
quantity: {
type: Number,
required: true
}
}]
},
Which of two codes are the best for performance ?