SHARE
TWEET

Untitled

a guest Sep 5th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const usersDb = await User.find({}).exec();
  2.   usersDb.forEach(async user => {
  3.     const orders = await newGetOrders(user);
  4.     orders.deliveryOrders.forEach(async order => {
  5.       const userWithOrders = await User.findOne({ organizationId: order.organization ,  orderIds: { "$in": order.orderId }  }).exec();
  6.       if (userWithOrders == null) {
  7.         const us = await User.findOne({ organizationId: order.organization }).exec();
  8.         us.orderIds.push(order.orderId);
  9.         await us.save();
  10.       }
  11.     })
  12.   });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top