Skip to content

Commit

Permalink
fix(UpdateMongoOperation): Fixed how the resource id is set in the up…
Browse files Browse the repository at this point in the history
…date doc
  • Loading branch information
0xfede committed Sep 19, 2017
1 parent 72bb739 commit 2ee4a33
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/mongo/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,10 @@ export class UpdateMongoOperation extends MongoOperation {
}
async prepareDoc(job:MongoJob): Promise<MongoJob> {
let out = _.cloneDeep(job.req.body);
if(this.resource.id === '_id' && this.resource.idIsObjectId) {
out['' + this.resource.id] = new mongo.ObjectID(job.req.params.id);
} else {
if(this.resource.id !== '_id') {
delete out._id;
out['' + this.resource.id] = job.req.params.id;
}
out['' + this.resource.id] = this.resource.idIsObjectId ? new mongo.ObjectID(job.req.params.id) : job.req.params.id;
delete out._metadata;
job.doc = {
$set: out
Expand Down

0 comments on commit 2ee4a33

Please sign in to comment.