Command.max(value: any): Command

View Markdown

Last edited on 2026-07-04

Supported on: Mini Program 2.8.3, Cloud Function 1.2.1, Web

The update operator. Given a value, the update is performed only if the value is greater than the current field value.

Parameters

value: any

Return Values

Command

Sample Code

If the field progress < 50, update it to 50

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