From e0fafa89b0c00e090417029a5bb117cfa3f36645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=91=95=C6=B3=E1=97=B7=E1=97=B4=E1=96=87=E4=B8=8533?= =?UTF-8?q?=E1=91=8E=E2=84=A2=20=20=E3=8B=9B=E2=8E=A0?= <17134633+CyberT33N@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:43:11 +0200 Subject: [PATCH 1/3] Added option updateDeep to defaultOptions --- src/express-restify-mongoose.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/express-restify-mongoose.ts b/src/express-restify-mongoose.ts index d426cf3..f1f220c 100644 --- a/src/express-restify-mongoose.ts +++ b/src/express-restify-mongoose.ts @@ -33,6 +33,7 @@ const defaultOptions: Omit = preRead: [], preUpdate: [], preDelete: [], + updateDeep: true, }; const filter = new Filter(); From b0f40850573377cdbbc62b6a3bb94e97b50b0dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=91=95=C6=B3=E1=97=B7=E1=97=B4=E1=96=87=E4=B8=8533?= =?UTF-8?q?=E1=91=8E=E2=84=A2=20=20=E3=8B=9B=E2=8E=A0?= <17134633+CyberT33N@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:46:01 +0200 Subject: [PATCH 2/3] Update operations.ts --- src/operations.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/operations.ts b/src/operations.ts index 245e165..992ab66 100644 --- a/src/operations.ts +++ b/src/operations.ts @@ -23,6 +23,7 @@ export function operations( | "runValidators" | "totalCountHeader" | "upsert" + | "updateDeep" >, filter: Filter ) { @@ -324,7 +325,11 @@ export function operations( return dst; } - const cleanBody = moredots(depopulate(req.body)); + let cleanBody = depopulate(req.body); + + if (options.updateDeep) { + cleanBody = moredots(cleanBody); + } if (options.findOneAndUpdate) { options.contextFilter(contextModel, req, (filteredContext) => { From 579de661b6c022322f6e202a20a0380cc709a5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=91=95=C6=B3=E1=97=B7=E1=97=B4=E1=96=87=E4=B8=8533?= =?UTF-8?q?=E1=91=8E=E2=84=A2=20=20=E3=8B=9B=E2=8E=A0?= <17134633+CyberT33N@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:07:50 +0200 Subject: [PATCH 3/3] Added option updateDeep to types.ts --- src/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types.ts b/src/types.ts index 3d52dce..40f12ec 100644 --- a/src/types.ts +++ b/src/types.ts @@ -57,6 +57,7 @@ export type Options = { preRead: RequestHandler | RequestHandler[]; preUpdate: RequestHandler | RequestHandler[]; preDelete: RequestHandler | RequestHandler[]; + updateDeep: boolean; access?: (req: Request) => Access | Promise; contextFilter: ( model: mongoose.Model,