For some endpoints I get a function back when called instead of the actual values (code at the end). It looks like that it only appears for nested endpoints through my Patient model. E.g. localhost:3000/api/Patients/{id}/MeasDescPatRels However this works fine: localhost:3000/api/Patients/{id}/MeasuredDataPoints In my webapp it is not really a problem, apparently the returned function is just called by JS and gives me the correct data. However I have an android app calling the exact same endpoints.
Returned function:
"function (condOrRefresh, options, cb) {\n if (arguments.length === 0) {\n if (typeof f.value === 'function') {\n return f.value(self);\n } else if (self.__cachedRelations) {\n return self.__cachedRelations[name];\n }\n } else {\n if (typeof condOrRefresh === 'function' &&\n options === undefined && cb === undefined) {\n // customer.orders(cb)\n cb = condOrRefresh;\n options = {};\n condOrRefresh = undefined;\n } else if (typeof options === 'function' && cb === undefined) {\n // customer.orders(condOrRefresh, cb);\n cb = options;\n options = {};\n }\n options = options || {};\n // Check if there is a through model\n // see https://github.com/strongloop/loopback/issues/1076\n if (f._scope.collect &&\n condOrRefresh !== null && typeof condOrRefresh === 'object') {\n //extract the paging filters to the through model\n ['limit', 'offset', 'skip', 'order'].forEach(function(pagerFilter) {\n if (typeof(condOrRefresh[pagerFilter]) !== 'undefined') {\n f._scope[pagerFilter] = condOrRefresh[pagerFilter];\n delete condOrRefresh[pagerFilter];\n }\n });\n // Adjust the include so that the condition will be applied to\n // the target model\n f._scope.include = {\n relation: f._scope.collect,\n scope: condOrRefresh,\n };\n condOrRefresh = {};\n }\n return definition.related(self, f._scope, condOrRefresh, options, cb);\n }\n }"
MeasDescPatRels model (not working):
{
"name": "MeasDescPatRel",
"base": "PersistedModel",
"strict": false,
"idInjection": false,
"options": {
"validateUpsert": true
},
"properties": {
"reminderData": {
"type": "object"
},
"alarmData": {
"type": "object"
}
},
"validations": [],
"relations": {
"patient": {
"type": "belongsTo",
"model": "Patient",
"foreignKey": "patientId"
},
"measurementDescription": {
"type": "belongsTo",
"model": "MeasurementDescription",
"foreignKey": ""
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
],
"methods": {}
}
HomeGateway model (not working):
{
"name": "HomeGateWay",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"model": {
"type": "string",
"required": true
},
"version": {
"type": "string",
"required": true
},
"onlineStatus": {
"type": "boolean",
"required": true
},
"macAdress": {
"type": "string",
"id": true,
"required": true
}
},
"validations": [],
"relations": {
"patient": {
"type": "belongsTo",
"model": "Patient",
"foreignKey": ""
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
],
"methods": {}
}
MeasuredDataPoint model (working):
{
"name": "MeasuredDataPoint",
"base": "PersistedModel",
"strict": false,
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"created": {
"type": "date",
"required": false
},
"timestamp": {
"type": "date",
"required": false
},
"lastUpdated": {
"type": "date",
"required": false
}
},
"validations": [],
"relations": {
"measurementDescription": {
"type": "belongsTo",
"model": "MeasurementDescription",
"foreignKey": ""
},
"patient": {
"type": "belongsTo",
"model": "Patient",
"foreignKey": "patientId"
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
],
"methods": {}
}
via Shrimbo
No comments:
Post a Comment