I originally have posted this question on [stackoverflow][1] but I got no response. Hoping I can get some help over here:
Let's say I have the following model definition:
{
"name": "Report",
"idInjection": true,
"trackChanges": true,
"mongodb": {
"collection": "report"
},
"properties": {
"resource" : {"type": "String"},
"date" : {"type": "Date"},
"people" : [ {
// Here's where I like to have an id property.
"role" : {"type": "String"},
"hours" : {"type": "Number"}
} ],
"name" : {"type": "String"}
},
"validations": [],
"relations": {},
"acls": [],
"methods": []
}
Now I want to have id property in each object in people array(to be accessed with like report.people[0].id) and it should be **casted** to ObjectId on inserts and updates. But well, loopback doesn't have an `ObjectId` type and the only way seems to be using relations but then how should the foreign key be?
Is there any way to have the id property casted to ObjectId on inserts and updates?