From fa5a73d37d04fdfc7a74b72060badc327a09105b Mon Sep 17 00:00:00 2001 From: chin Date: Thu, 28 Oct 2021 18:34:47 +0800 Subject: [PATCH] fix: mongoose response document will fill undefined in not exist field The model will fill undefined in not exist field. Use _doc to get original object --- FHIR-mongoose-Models-Generator/resourceGenerator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FHIR-mongoose-Models-Generator/resourceGenerator.js b/FHIR-mongoose-Models-Generator/resourceGenerator.js index 62907e95..66df6f9f 100644 --- a/FHIR-mongoose-Models-Generator/resourceGenerator.js +++ b/FHIR-mongoose-Models-Generator/resourceGenerator.js @@ -243,7 +243,7 @@ function generateResourceSchema (type) { });\r\n ${type}Schema.methods.getFHIRField = function () { - let result = this.toObject(); + let result = this._doc(); delete result._id; delete result.__v; if (_.get(result, "myCollection")) {