两个集合中的mongoose更新元素

我有两个Schema

var recipeSchema = new mongoose.Schema({ name: String, products: [{ product: Product, weight: Number }] }) var productSchema = new mongoose.Schema({ name: String, weight: Number, price: Number }) module.exports.updateProduct = function(req, res){ var productId = req.params.productId; Product .findById(productId) .exec(function(err, product){ if(err){ console.log("Error finding product"); res .status(500) .json(err); } else if (!product){ res .status(404) .json({ "message": "Product ID not found" }); } else { product.name = req.body.name; product.weight = parseInt(req.body.weight); product.price = parseFloat(req.body.price).toFixed(2); product.save(function(err, updatedProduct){ if(err){ res .status(500) .json(err); } else { res .status(204) .json(); } }) } }) } 

我想一次更新两个文档中的产品。 我在产品集合中写了更新Product的一段代码。 但我不知道如何更新食谱的产品。

例如:食谱:

 { "_id" : ObjectId("596d281a4b49abec4abd3d48"), "name" : "Cake", "products" : [ { "product" : { "_id" : ObjectId("596d27a24b49abec4abd3d3c"), "name" : "sugar", "price" : 12.34 }, "weight" : 100 } ] } 

产品

 { "_id" : ObjectId("596d27a24b49abec4abd3d3c"), "name" : "sugar", "price" : 12.34 } 

我想一次更新产品和食谱的产品。 可能吗?