When I execute the code below I don't get any documents in Mongoose for "Detail"-collection - see line 11 in the code. Why doesn't it work? I am grateful for every tip.
Cats.find({ user: req.params.user }, function (err, product) { | |
if (err) { | |
return res.send({ isFound: false }); | |
} | |
if (!product) { | |
return res.send({ isFound: false }); | |
} | |
product.forEach(element => { | |
element.orderid = req.params.smaorderid | |
Detail.create(element, function (err, orderitems) { | |
if (err) { | |
console.log(err) | |
return res.send({isCreated: false}) | |
} | |
}) | |
}); | |
return res.send({isCreated: true}) | |
}) |
I made a mistake in the previous code. Therefore it is solved now.
Top comments (0)