- Hands-On RESTful Web Services with TypeScript 3
- Biharck Muniz Araújo
- 239字
- 2021-07-02 12:19:21
Filtering
Sometimes, a resource contains more data than is needed by the requester. In this case, the API should have the ability to filter elements in or out from the resource.
Filtering can be implemented as a query parameter that's named for the field to be filtered on. The value needs to be the value it needs to filter for. You can refer to the definition of filtering at https://jsonapi.org/recommendations/#filtering.
For example, the following is a request for all items associated with a particular order with a name of coffee:
GET http://<HOST>/order/<id>/items?filter[name]=coffee
Also, multiple filter values could be combined in a comma-separated list:
GET http://<HOST>/order/<id>/items?filter[name]=coffee,milk
Furthermore, multiple filters can also be applied to the same request as another filter:
GET http://<HOST>/order/<id>/items?filter[name]=coffee,milk&filter[category]=organic
There is also the possibility to include the following operators:
- in: Getting items within the range between 5 and 20:
GET http://<HOST>/order/<id>/items?filter[size]=in:5,20
- nin: Getting items that are out of a range:
GET http://<HOST>/order/<id>/items?filter[size]=nin:5,20
- neq: Getting items not matching a specific value:
GET http://<HOST>/order/<id>/items?filter[category]=neq:built-in
- gt: Getting items greater than a specific value:
GET http://<HOST>/order/<id>/items?filter[size]=gt:5
- gte: Getting items greater than a specific value, inclusive:
GET http://<HOST>/order/<id>/items?filter[size]=gte:5
- lt: Getting items lower than a specific value:
GET http://<HOST>/order/<id>/items?filter[size]=lt:25
- lte: Getting items lower than a specific value, inclusive:
GET http://<HOST>/order/<id>/items?filter[size]=lte:25
- 郎景和院士“關(guān)愛女性健康”系列:婦科腫瘤的故事
- 2021中國腫瘤登記年報(bào)(漢英)
- 性傳播疾病實(shí)驗(yàn)室檢測指南
- 鼻咽癌標(biāo)準(zhǔn)數(shù)據(jù)集(2023版)
- 高脂血癥百家百方
- 全科常見急癥診療手冊
- 斜視臨床診療
- 硅橡膠修補(bǔ)關(guān)節(jié)軟骨的實(shí)驗(yàn)研究
- 結(jié)直腸癌老年患者治療與康復(fù)
- 肝臟外科名家手術(shù)精粹
- 呼吸與危重癥醫(yī)學(xué)2014-2015
- 重癥肺病名醫(yī)學(xué)術(shù)經(jīng)驗(yàn)傳承與實(shí)踐
- 老魚頭的麻醉隨筆
- 深井效應(yīng)
- 視神經(jīng)疾病中西醫(yī)結(jié)合診治(第2版)