mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-02 16:09:08 +02:00
Update house-keeping policy (#185)
This commit is contained in:
parent
7b30342803
commit
8f4bdad8c5
7 changed files with 289 additions and 39 deletions
|
@ -12,7 +12,7 @@ export const softDeleteMiddleware = (
|
|||
// Delete queries
|
||||
// Change action to an update
|
||||
params.action = "update";
|
||||
params.args["data"] = { deleted: true };
|
||||
params.args["data"] = { deleted: true, deletedAt: new Date() };
|
||||
}
|
||||
if (params.action == "deleteMany") {
|
||||
// Delete many queries
|
||||
|
@ -20,7 +20,7 @@ export const softDeleteMiddleware = (
|
|||
if (params.args.data != undefined) {
|
||||
params.args.data["deleted"] = true;
|
||||
} else {
|
||||
params.args["data"] = { deleted: true };
|
||||
params.args["data"] = { deleted: true, deletedAt: new Date() };
|
||||
}
|
||||
}
|
||||
if (params.action === "findUnique" || params.action === "findFirst") {
|
||||
|
@ -29,7 +29,7 @@ export const softDeleteMiddleware = (
|
|||
params.action = "findFirst";
|
||||
// Add 'deleted' filter
|
||||
// ID filter maintained
|
||||
params.args.where["deleted"] = false;
|
||||
params.args.where["deleted"] = params.args.where["deleted"] || false;
|
||||
}
|
||||
}
|
||||
return next(params);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue