Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Promise.all(products.map((productName, i) => {
- const quantity = Number(quantities[i]);
- return new Promise((resolve, reject) => {
- const _product = Products.findOne({ label: productName });
- return _product.exec();
- })
- .then((product) => {
- customer.inventory.push({
- someData
- });
- customer.markModified("inventory");
- return customer.save()
- })
- .then((customer) => {
- user.sales.push({
- someData
- });
- return user.save();
- })
- }))
- .then(() => {
- res.json({
- message: "Sales successful",
- status: true
- });
- })
- .catch((e) => {
- res.json({
- message: "Sales failed to be added",
- status: false
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement