3***@qq.com
3***@qq.com
  • 发布:2025-04-21 17:55
  • 更新:2025-04-26 11:27
  • 阅读:156

数据库使用where查询时,如何同时使用and和or的查询条件?

分类:uniCloud

假设我的数据结构是这样:
{
_id:'aa111',
index:'test22222',
content:'test11111'
}
我需要从数据库查询数据,查询条件为:_id中包含‘aa’,同时:‘index’包含‘test’或‘content’包含‘test’,
我用
const res =await db.collection(cltn).where({
_id:new RegExp(bookid,"ig"),
$or:[{
content:new RegExp(m,"ig")
},{
index:new RegExp(m,"ig")
}]
}).limit(1000).get()
查询不到结果,是哪里错了?请问正确写法是什么?

2025-04-21 17:55 负责人:无 分享
已邀请:
DCloud_uniCloud_CRL

DCloud_uniCloud_CRL

要回复问题请先登录注册