0

So I'm trying to make a order model which holds the information of all the products in the order. This is the schema design for it

productIds: {
        type: [{
            id: {
                type: mongoose.Schema.Types.ObjectId,
                ref: "Product"
            },
            qty: Number
        }],
        required: true
    }

Is there a way to populate the id with the actual product? I've tried using this

await Order.findById(id).populate("userId").populate("productIds")

But that doesn't populate it

0 Answers0