Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

SDK database Command query field operator


May 20, 2021 WeChat Mini Program Development Document


Table of contents


Command.exists(value: boolean): Command

Support: Small program 2.8.3, cloud function 1.2.1, Web

Determine if a field exists

Parameters

value: boolean

Returns a value

Command

The sample code

Find records that have tags fields

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

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

Support: Small program 2.8.3, cloud function 1.2.1, Web

The query filter operator, given the divisor and the remainder, requires the field to be divided when the value % divisor is the remainder.

Parameters

divisor: number

remainder: number

Returns a value

Command

The sample code

Find a record of a field with a progress of 10

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