我有一个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
的调用根本不会产生任何结果:空数组。
有很多Establishment
个Distance
大于30;实际上在其他属性上使用where
过滤器也会产生一个空数组。我能错过什么?
答案 0 :(得分:0)
正如我在评论中提到的,它区分大小写,我在应用程序上对其进行了修改以确定它。
它应该是:
http://localhost:3000/api/Establishments?filter[where][Distance][gt]=30
或者您可以尝试使用以下格式:
http://localhost:3000/api/Establishments?filter={"where":{"Distance":{"gt":30}}}