var ObjSchema = new Schema ({ productId: {type: Schema.Types.ObjectId, ref: "M_Data_Product", default: null}, qty: {type: Number, default: 0}, price: {type: Float, default: 0}, });Este es mi modelo de carrito.
var ObjSchema = new Schema({ name: {type: String, default: null}, categoryId: {type: Schema.Types.ObjectId, ref: "M_Data_Category", default: null} });Este es el modelo de producto.
Quiero almacenar registros por categoría en particular. ¿Cómo debo encontrar?
Model.aggregate([ { "$lookup": { "from": "Product", //collection name of product "localField": "productId", "foreignField": "_id", "as": "product" } }, { $match:{"product.categoryId":"exampleId"} } ])