Skip to content

Commit

Permalink
updateMany: Add current value to mapping function if any
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjD90 committed May 3, 2019
1 parent a7c50d3 commit 043cd94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/client.ts
Expand Up @@ -492,7 +492,7 @@ export class MongoClient<U extends BaseMongoObject, L extends BaseMongoObject> {
userId: string,
lockNewFields: boolean,
query?: string | StringMap<(keyValue: any, entity: Partial<U>, key: string) => any>,
mapFunction?: (entity: Partial<U>) => Promise<Partial<U>>,
mapFunction?: (entity: Partial<U>, existingEntity?: U) => Promise<Partial<U>>,
onlyInsertFieldsKey?: string[],
forceEditLockFields?: boolean,
): Promise<UpdateManyQuery[]> {
Expand All @@ -508,7 +508,7 @@ export class MongoClient<U extends BaseMongoObject, L extends BaseMongoObject> {
}
if (currentValue) {
if (!!mapFunction) {
entity = await mapFunction(entity);
entity = await mapFunction(entity, currentValue);
}
MongoClient.removeEmptyDeep(entity);

Expand Down

0 comments on commit 043cd94

Please sign in to comment.