From 9439334decc7ba01ebff7d7a270cceafd22e55e4 Mon Sep 17 00:00:00 2001 From: chin Date: Fri, 14 Jan 2022 23:58:49 +0800 Subject: [PATCH] fix: `resource.meta` incorrect after updating --- 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..15821c7f 100644 --- a/FHIR-mongoose-Models-Generator/resourceGenerator.js +++ b/FHIR-mongoose-Models-Generator/resourceGenerator.js @@ -319,7 +319,7 @@ function generateResourceSchema (type) { ${type}Schema.pre('findOneAndUpdate' , async function (next) { const docToUpdate = await this.model.findOne(this.getFilter()); let version = Number(docToUpdate.meta.versionId); - this._update.$set.meta = {}; + this._update.$set.meta = docToUpdate.meta; this._update.$set.meta.versionId = String(version+1); this._update.$set.meta.lastUpdated = new Date(); return next();