# db.command.unshift

Update command. Prefix one or more values to the head 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 unshift(values: any[]): Command

Sample code

const _ = db.command
db.collection('todos').doc('doc-id').update({
  data: {
    tags: _.unshift(['mini-program', 'cloud'])
  }
})