SDK數(shù)據(jù)庫(kù) Command·查詢·字段操作符

2022-05-12 16:53 更新

Command.exists(value: boolean): Command

支持端:小程序 2.8.3, 云函數(shù) 1.2.1, Web

判斷字段是否存在

參數(shù)

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, 云函數(shù) 1.2.1, Web

查詢篩選操作符,給定除數(shù) divisor 和余數(shù) remainder,要求字段作為被除數(shù)時(shí) value % divisor = remainder。

參數(shù)

divisor: number

remainder: number

返回值

Command

示例代碼

找出進(jìn)度為 10 的倍數(shù)的字段的記錄

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


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)