如何在Directus中通过URL使用_between过滤两个值间的数据?
Directus _between过滤条件的URL配置方法
要在Directus接口中使用_between过滤数值区间数据,你需要给该条件传入包含下限值和上限值的数组,具体在URL中的配置方式如下:
- 在
filter[price][_between]后分别添加[0]和[1]来指定区间的最小值和最大值,格式为:filter[price][_between][0]=最小值&filter[price][_between][1]=最大值
完整示例URL
假设你要筛选价格在100到500之间的产品,补全后的URL如下:
http://localhost:8055/items/product?fields=title,price,id,surface,city.name,thumbnail,rooms&filter[price][_between][0]=100&filter[price][_between][1]=500
说明
[0]对应区间的最小值(即价格≥100)[1]对应区间的最大值(即价格≤500)- Directus会解析这个数组参数,返回符合该数值区间的产品数据
内容的提问来源于stack exchange,提问作者Helmi
相关产品推荐
相关产品推荐

