Command.bit(object: Object): Command

View Markdown

Last edited on 2026-07-04

Supported by: Mini Program 2.8.3, Cloud Functions 1.2.1, Web

Bitwise update operator. Performs bitwise operations on a field, supporting and/or/xor operations.

Parameters

object: Object

Attribute Type Default Value Required Description
and number No Integer for bitwise AND operation
or number No Integer for bitwise OR operation
xor number No Integer for bitwise XOR operation

Return Value

Command

Usage

Select one of and/or/xor

Sample Code

const _ = db.command
db.collection('todos').doc('doc-id').update({
  data: {
    // Assuming the original value is 2, it will be 3 after the operation
    progress: _.bit({
      or: 1
    })
  }
})