From 043cd942ddea1ae00a6045858d73ded0684f2fee Mon Sep 17 00:00:00 2001 From: Benjamin Daniel Date: Fri, 3 May 2019 10:00:42 +0200 Subject: [PATCH] updateMany: Add current value to mapping function if any --- src/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.ts b/src/client.ts index ab75d67..33b314a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -492,7 +492,7 @@ export class MongoClient { userId: string, lockNewFields: boolean, query?: string | StringMap<(keyValue: any, entity: Partial, key: string) => any>, - mapFunction?: (entity: Partial) => Promise>, + mapFunction?: (entity: Partial, existingEntity?: U) => Promise>, onlyInsertFieldsKey?: string[], forceEditLockFields?: boolean, ): Promise { @@ -508,7 +508,7 @@ export class MongoClient { } if (currentValue) { if (!!mapFunction) { - entity = await mapFunction(entity); + entity = await mapFunction(entity, currentValue); } MongoClient.removeEmptyDeep(entity);