PATIENT MODEL
{
"name": "Patient",
"base": "PersistedModel",
"idInjection": true,
"properties": {
"createdDate": {
"type": "date"
}
},
"validations": [],
"relations": {
"profile": {
"type": "hasOne",
"model": "Profile",
"foreignKey": "profileID"
}
},
"acls": [],
"methods": []
}
PATIENT TABLE
id (INT)
createdDate (DATETIME)
modifiedDate (DATETIME)
PROFILE MODEL
{
"name": "Profile",
"base": "Model",
"idInjection": true,
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
}
},
"validations": [],
"relations": {
"patient": {
"type": "belongsTo",
"model": "Patient",
"foreignKey": "profileID"
}
},
"acls": [],
"methods": []
}
PROFILE TABLE
id (INT)
firstName (VARCHAR)
lastName (VARCHAR)
Q: When I save the model, I POST following to /api/patients/ endpoint
{
"ceratedDate": "2012-12-12",
"modifiedDate": "2012-12-13",
"profile": {
"firstName": "John",
"lastName": "Wick"
}
}
The way I expect it to work is save createdDate and modifiedDate to Patient Table and save firstName and lastName to Profile Table.
Why is this not working ? Do I have to do any additional work to get it to work ? When GETting it it only returns Patient model without profile object in it. Is that the same issue I guess ?
Any help is appreciated, thanks !