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

const allOrderItems = async() => {
    return await OrderItems.findAll()
}

const byIdOrderItem = async(id) => {
    return await OrderItems.findByPk(id)
}

const createOrderItem = async(body) => {
    return await OrderItems.create(body)
}

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

const deleteOrderItem = async(id) => {
    return await OrderItems.destroy({
        where:{id}
    })
}
module.exports = {
    allOrderItems,
    byIdOrderItem,
    createOrderItem,
    updateOrderItem,
    deleteOrderItem
};
