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

const allPayment = async() => {
    return await Payment.findAll()
}

const byIdPayment = async(id) => {
    return await Payment.findByPk(id)
}

const createPayment = async(body) => {
    return await Payment.create(body)
}

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

const deletePayment = async(id) => {
    return await Payment.destroy({
        where:{id}
    })
}
module.exports = {
      allPayment,
       byIdPayment,
       createPayment,
       updatePayment,
       deletePayment
};
