Large commit, multiple projects/labs
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import db from "../config/db.js";
|
||||
|
||||
export const getCustomers = async (customer) => {
|
||||
const [rows] = await db.query("SELECT * FROM customers");
|
||||
return rows;
|
||||
};
|
||||
|
||||
export const addCustomer = async (customer) => {
|
||||
const[result] = await db.query(
|
||||
"INSERT INTO customers (name, email, phone) VALUES (?, ?, ?)",
|
||||
[customer.name, customer.email, customer.phone]
|
||||
);
|
||||
return result;
|
||||
};
|
||||
|
||||
export const updateCustomer = async(id, customer) => {
|
||||
const [result] = await db.query(
|
||||
"UPDATE customers SET name = ?, email = ?, phone = ? WHERE customer_id = ?",
|
||||
[customer.name, customer.email, customer.phone, id]
|
||||
);
|
||||
return result;
|
||||
};
|
||||
|
||||
export const deleteCustomer = async (id) => {
|
||||
const[result] = await db.query(
|
||||
"DELETE FROM customers WHERE customer_id = ?",
|
||||
[id]
|
||||
);
|
||||
return result;
|
||||
};
|
||||
Reference in New Issue
Block a user