const db = require("../../db/models/index.js");
const {User} = db;

const allUser = async() => {
    return await User.findAll()
}

const byIdUser = async(id) => {
    return await User.findByPk(id)
}

const createUser = async(body) => {
    return await User.create(body)
}

const updateUser = async(id, body) => {
    const data = await User.findByPk(id);
    await data.update(body);
    return data;
}

const deleteUser = async(id) => {
    return await User.destroy({
        where:{id}
    })
}
module.exports = {
    allUser,
    byIdUser,
    createUser,
    updateUser,
    deleteUser
};
