html52.com
我爱小程序-开发者交流社区

云开发数据库数组字段,多个值in怎么查?

https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/query-array-object.html

如文档中:

集合下一条记录:

{
  "numbers": [10, 20, 30]
}

如果查询包含20的,可以用

db.collection('todos').where({
  numbers: 20
}).get()


请问如果查询包含10且包含20,或者查询包含10或者包含20的数据,应该怎么查呢?

网友回复

_人世间:

const db = wx.cloud.database();

const _ = db.command

db.collection('todos).where({

numbers: _.eq(20).or(_.eq(10))

}).get()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付