added feature: That no loan can be deleted and edited changelog accordingly
This commit is contained in:
@@ -17,7 +17,10 @@ export const getAllLoans = async () => {
|
||||
};
|
||||
|
||||
export const deleteLoanById = async (loanId) => {
|
||||
const [result] = await pool.query("DELETE FROM loans WHERE id = ?", [loanId]);
|
||||
const [result] = await pool.query(
|
||||
"UPDATE loans SET deleted = true, deleted_admin = true WHERE id = ?",
|
||||
[loanId],
|
||||
);
|
||||
if (result.affectedRows > 0) return { success: true };
|
||||
return { success: false };
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@ CREATE TABLE loans (
|
||||
loaned_items_id json NOT NULL DEFAULT ('[]'),
|
||||
loaned_items_name json NOT NULL DEFAULT ('[]'),
|
||||
deleted bool NOT NULL DEFAULT false,
|
||||
deleted_admin bool NOT NULL DEFAULT false,
|
||||
note varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
CHECK (loan_code REGEXP '^[0-9]{6}$')
|
||||
|
||||
Reference in New Issue
Block a user