Skip to content

Commit

Permalink
fix: backBoneElement not use getter with mongoose schema
Browse files Browse the repository at this point in the history
reason>
The options missing toObject, if not pass this option, the element will not use the getter function

fix: incorrect dateTime format

The date time is 24 hour format, small `h` mean 12 hour format so change to big `H`
  • Loading branch information
Chinlinlee committed Oct 24, 2021
1 parent 59c0153 commit 0776c38
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion FHIR-mongoose-Models-Generator/resourceGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ async function generateSchema (type) {
}
}
let schemaStr = JSON.stringify(schema , null , 4).replace(/\"/gm , '')
let code = `module.exports = new mongoose.Schema (${schemaStr.replace(/\\/gm , '"')} , { _id : false });`;
let code = `module.exports = new mongoose.Schema (${schemaStr.replace(/\\/gm , '"')} , {
_id : false ,
id: false,
toObject: {
getters: true
}
});`;
code = `${importLib}${code}`;
fs.writeFileSync(`./models/mongodb/FHIRDataTypesSchema/${type}.js` , beautify(code , {indent_size : 4 ,pace_in_empty_paren: true }));
for (let i in schema) {
Expand Down
2 changes: 1 addition & 1 deletion models/mongodb/FHIRDataTypesSchema/dateTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
type: Date,
default: void 0,
get: function(v) {
return moment(v).format('YYYY-MM-DDThh:mm:ssZ');
return moment(v).format('YYYY-MM-DDTHH:mm:ssZ');
}
}
2 changes: 1 addition & 1 deletion models/mongodb/FHIRDataTypesSchema/instant.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const moment = require('moment');
module.exports = {
type: Date,
get: function(v) {
return moment(v).format('YYYY-MM-DDThh:mm:ss.SSSZ');
return moment(v).format("YYYY-MM-DDTHH:mm:ss.SSSZ");
} ,
default: void 0,
}

0 comments on commit 0776c38

Please sign in to comment.