2
我有一個簡單的模型對象與startDate和endDate屬性。Strongloop Loopback REST查詢和/或結合使用
我似乎無法用'和/或'和'之間'使用REST api進行查詢。我想查詢'startDate範圍'或'endDate範圍之間'。我本來以爲下面的查詢會工作:
?filter[where][or][0][event.startDate][between][0]=2017-01-15&filter[where][or][0][event.startDate][between][1]=2017-01-22&filter[where][or][1][event.endDate][between][0]=2017-01-15&filter[where][or][1][event.endDate][between][1]=2017-01-22
理想我也喜歡event.startDate和event.endDate但迴環之間的查詢不喜歡下面的查詢:
?filter[where][event.startDate][between][0]=2017-01-15&filter[where][event.endDate][between][1]=2017-01-22
查詢獨立工作得很好:
?filter[where][event.startDate][between][0]=2017-01-15&filter[where][event.startDate][between][1]=2017-01-22
?filter[where][event.endDate][between][0]=2017-01-15&filter[where][event.endDate][between][1]=2017-01-22
這裏是我的模型定義:
個型號/ event.json
{
"name": "event",
"plural": "events",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"name": {
"type": "string",
"required": false
},
"startDate": {
"type": "date",
"required": false
},
"endDate": {
"type": "date",
"required": false
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
好戲......非常靈活。 – Abhishek