import {Users, sequelize} from "../../models/index";

module.exports = async (req, res, next) => {
    if(req.body.id) {
        const userData = await Users.findOne({
            where: {
                id: req.body.id
            },
            attributes: ['name', 'surname', 'phone', 'email', 'city', 'apartment', 'street', 'home']
        });

        if(!userData) {

        }else {
            req.body.userData = userData.dataValues;
            next();
        }
    }else {
        next();
    }

};