Command.mul(value: number): Command

View Markdown

Last edited on 2026-07-04

Supported platforms: Mini Program, Cloud Functions, Web

Update operator. This is an atomic operation used to indicate multiplying a field by a specified value.

Parameters

value: number

Multiplicative factor; can be positive or negative

Return Value

Command

Atomic Self-Multiplication

When multiple users write simultaneously, the database performs self-multiplication on the field for each operation, preventing later writes from overwriting earlier ones.

Sample Code

Multiply the progress of a todo by 10:

const _ = db.command
db.collection('todos').doc('todo-id').update({
  data: {
    progress: _.mul(10)
  }
})