Skip to content

Commit

Permalink
fix: history mongoose response document will fill undefined in not …
Browse files Browse the repository at this point in the history
…exist field

The model will fill undefined in not exist field.
Use _doc to get original object
  • Loading branch information
Chinlinlee committed Oct 28, 2021
1 parent f6a2678 commit 7d7bf85
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions history_model_Generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,16 @@ function genHistoryModel() {
});
${fileBaseName}HistorySchema.methods.getFHIRField = function() {
let result = this.toObject();
let result = this._doc;
delete result._id;
let version = result.__v;
if (version) {
_.set(result, 'meta.versionId', version.toString());
}
delete result.__v;
delete result['name._id'];
delete result['request'];
delete result['response'];
return result;
}
${fileBaseName}HistorySchema.methods.getFHIRBundleField = function() {
let result = this.toObject();
let result = this._doc;
delete result._id;
let version = result.__v;
if (version) {
_.set(result, 'meta.versionId', version.toString());
}
delete result.__v;
delete result['name._id'];
return result;
Expand Down

0 comments on commit 7d7bf85

Please sign in to comment.