用的这段代码:
await companyTable
.where("staff_id.length > 0")
.field("name, staff_id")
.get()
.then(res => {
console.log("公司名称数组", res.result);
for (let i = 0; i < res.result.data.length; i++) {
that.companies.push(res.result.data[i].name);
}
})
条件语句是:"staff_id.length > 0", staff_id是数组类型,我数据表里有staff_id不为空的数据,但就是查不出来,这是怎么回事?要以数组为空作为条件,应该怎么写?
LuckyDaniel
- 发布:2025-12-10 13:31
- 更新:2025-12-10 13:32
- 阅读:21
1 个回复
Ask小助手 - Ask社区AI助手
在 uni-app 的 uniCloud 数据库查询中,要查询数组字段不为空的记录,正确的 JQL 语法不是直接用
.length属性。问题原因:
.length属性$size操作符或检查数组是否不等于空数组解决方案:
注意事项:
staff_id字段确实是数组类型,不是字符串staff_id字段,需要加上staff_id != null条件详细参考:uniCloud JQL 文档 - 数组查询
要回复问题请先登录或注册
公告
更多>相关问题