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);