我想获取cities为空数组以及包含上海市的结果,使用db.collection('opendb-news-articles').where("size(cities)==0 || cities.name=='上海市'")时,最终结果只有size(cities)==0的结果。麻烦官方大大帮忙看下啥原因,谢谢。
y***@yeah.net
- 发布:2022-08-02 16:46
- 更新:2022-08-05 12:08
- 阅读:237
unicloud使用where("size(cities)==0 || cities.name=='上海市'"),最终结果只有size(cities)==0的结果。
分类:uniCloud
y***@yeah.net (作者)
{"cities":[{"code":"120100","user":true,"name":"天津市"},{"code":"110100","user":true,"name":"北京市"}],"publish_ip":"127.0.0.1","last_modify_ip":"127.0.0.1"}
{"cities":[],"publish_ip":"127.0.0.1","last_modify_ip":"127.0.0.1"}
{"cities":[{"code":"330100","user":true,"name":"杭州市"}],"publish_ip":"127.0.0.1","last_modify_ip":"127.0.0.1"}
2022-08-12 11:16
y***@yeah.net (作者)
谢谢大佬
2022-08-12 11:16
DCloud_uniCloud_WYQ
回复 y***@yeah.net: 使用了数据库运算方法后整个where条件都会被转化为复杂查询条件,此时cities.name不能用于匹配满足条件的数组,可以使用如下写法,我们看下有没有更好的方式
.where("size(cities)==0 || size(filter(cities, 'city', '$$city.name' == '杭州市')) > 0")
2022-08-15 14:37
y***@yeah.net (作者)
回复 DCloud_uniCloud_WYQ: 谢谢大佬
2022-08-19 16:42