晴川云小程序教程:SDK数据库 Command·查询·字段操作符

Command.exists(value: boolean): Command

支持端:小程序 2.8.3, 云函数 1.2.1, Web

判断字段是否存在

参数

value: boolean

返回值

Command

示例代码

找出存在 tags 字段的记录

const _ = db.command
db.collection('todos').where({
  tags: _.exists(true)
})
.get({
  success: console.log,
  fail: console.error
})

Command.mod(divisor: number, remainder: number): Command

支持端:小程序 2.8.3, 云函数 1.2.1, Web

查询筛选操作符,给定除数 divisor 和余数 remainder,要求字段作为被除数时 value % divisor = remainder。

参数

divisor: number

remainder: number

返回值

Command

示例代码

找出进度为 10 的倍数的字段的记录

const _ = db.command
db.collection('todos').where({
  progress: _.mod(10, 0)
})
.get({
  success: console.log,
  fail: console.error
})

原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/16398.html

(0)
晴川运维晴川运维
上一篇 2025年10月22日
下一篇 2025年10月22日

相关推荐

发表回复

登录后才能评论