Skip to content

Commit 8ba5f08

Browse files
committed
Merge pull request #26 from joshuajabbour/set-id-during-put-update
Always set "id" field during PUT updates
2 parents 1e0a56b + 69a34e7 commit 8ba5f08

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,13 @@ class Service {
131131

132132
let { query, options } = multiOptions(id, params, this.id);
133133

134-
// We can not update the id
135-
delete data[this.id];
134+
if (this.id === '_id') {
135+
// We can not update the id
136+
delete data[this.id];
137+
} else {
138+
// If not using the default Mongo _id field, the id must be set to its previous value
139+
data[this.id] = id;
140+
}
136141

137142
return this.Model
138143
.update(query, data, options)

0 commit comments

Comments
 (0)