import {Orders, sequelize} from "../../models";

const {Op} = sequelize;



module.exports = async (req, res, next) => {
    const {decryptedData} = req.body;

    Orders.findAll({
        where: {
            id: {
                [Op.or]: decryptedData.orderId
            }
        }
    }).then(orders => {
        orders.map((order, i, arr) => {
            order.update(decryptedData.dataForUpdate).then(() => {
                arr.length - 1 == i && (
                    next()
                )
            }).catch(err => next(err));
        });
    }).catch(err => next(err));
};