Skip to content

Commit

Permalink
add id alias for json object to override default _id
Browse files Browse the repository at this point in the history
  • Loading branch information
da-derekliang committed Apr 23, 2020
1 parent c2f9d43 commit 7796bfc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/moleculer-db-adapter-mongo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MongoDbAdapter {
*/
constructor(uri, opts, dbName) {
this.uri = uri,
this.opts = opts;
this.opts = opts || {};
this.dbName = dbName;
}

Expand Down Expand Up @@ -257,7 +257,7 @@ class MongoDbAdapter {
entityToObject(entity) {
let json = Object.assign({}, entity);
if (entity._id)
json._id = this.objectIDToString(entity._id);
json[this.opts.jsonId ? this.opts.jsonId : "_id"] = this.objectIDToString(entity._id);
return json;
}

Expand Down

0 comments on commit 7796bfc

Please sign in to comment.