Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const usersDb = await User.find({}).exec();
- usersDb.forEach(async user => {
- const orders = await newGetOrders(user);
- orders.deliveryOrders.forEach(async order => {
- const userWithOrders = await User.findOne({ organizationId: order.organization , orderIds: { "$in": order.orderId } }).exec();
- if (userWithOrders == null) {
- const us = await User.findOne({ organizationId: order.organization }).exec();
- us.orderIds.push(order.orderId);
- await us.save();
- }
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement