# db.command.push

Update command. Appends one or more values to the end of an array when the value of a field is the array. Alternatively, if the value of a field is empty, creates the field and sets the array as the incoming value.

Function signature:

function push(values: any[]): Command

Sample code

const _ = db.command
db.collection('todos').doc('doc-id').update({
  data: {
    tags: _.push(['mini-program', 'cloud'])
  }
})
点击咨询小助手