Hi,
I am coding loopback connector for couchbase, and stuck at the topic "include". As far as I can see, the "include" filter passes an array of strings which contains all the names of the models that are related to the current model. For example, here is the properties of the model "Ticket":
{
"name": "Ticket",
"base": "PersistedModel",
"properties": {
"id": {
"type": "String",
"id": true,
"required": true,
"index": true
}
},
"validations": [],
"relations": {
"actions": {
"type": "hasMany",
"model": "Action",
"foreignKey": "ticketID"
}
},
"acls": [],
"methods": []
}
It has one to many relations to the model "Action", the foreignKey is "ticketID". Therefore, when the filter looks like {"include":["Action"]}, I need to be able to read the properties of the model "Ticket", find the "foreignKey": "ticketID" of the relation "actions" so that I could write couchbase N1QL statement to process the query.
Question is: how can I access the properties of a model due to its name?
Thanks in advance for any help
Eric