【发布时间】:2017-11-06 05:10:12
【问题描述】:
我有一个带有单个简单模型的 LoopBack API,如下所示:
{
"name": "Establishment",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"Distance": {
"type": "number"
},
"EstablishmentId": {
"type": "number"
},
"EstablishmentType": {
"type": "string"
},
"Location": {
"type": "string"
},
"MinCost": {
"type": "number"
},
"Name": {
"type": "string"
},
"Stars": {
"type": "number"
},
"UserRating": {
"type": "number"
},
"UserRatingTitle": {
"type": "string"
},
"UserRatingCount": {
"type": "number"
},
"ImageUrl": {
"type": "string"
},
"ThumbnailUrl": {
"type": "string"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
对http://localhost:3000/api/Establishments 的简单调用会按预期返回所有结果;但是调用http://localhost:3000/api/Establishments?filter[where][distance][gt]=30 根本不会产生任何结果:一个空数组。
有很多Establishments 的Distance 大于30;实际上,在其他属性上使用 where 过滤器也会导致一个空数组。我可能会错过什么?
【问题讨论】:
-
可能是因为它区分大小写,请尝试将模型上的字段重命名为小写首字母或仅在过滤器中使用“距离”
标签: rest loopbackjs