Closed lafama closed 1 year ago
ObjectModel does not change the type of your data. If you need to apply custom casting rules like string to boolean or string to date, you need to define your own custom logic in a factory function or a class constructor.
function parseMyObject(json){
return MyModel ({
_id: new ObjectId(json._id),
isActive: json.isActive === "true",
code: json.code,
dateUpdated: new Date(json.dateUpdated)
})
}
Is there a way to load this Json string
to an Object that has the isActive cast to a boolean, id cast to Mongodb ObjectId and dateUpdated cast to Date object so it becomes