add : CRUD roles
This commit is contained in:
@@ -51,19 +51,23 @@ const getRoleByIdDb = async (id) => {
|
||||
|
||||
// Create role
|
||||
const createRoleDb = async (data) => {
|
||||
const roles = { ...data };
|
||||
|
||||
const { query, values } = pool.buildDynamicInsert("m_roles", {
|
||||
...data,
|
||||
created_at: new Date(),
|
||||
...roles,
|
||||
});
|
||||
|
||||
const result = await pool.query(query, values);
|
||||
return result.recordset[0]?.inserted_id || null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Update role
|
||||
const updateRoleDb = async (id, data) => {
|
||||
const { query, values } = pool.buildDynamicUpdate(
|
||||
"m_roles",
|
||||
{ ...data, updated_at: new Date() },
|
||||
{ ...data },
|
||||
{ role_id: id }
|
||||
);
|
||||
await pool.query(query, values);
|
||||
|
||||
Reference in New Issue
Block a user