db.command.unshift

更新指令,对一个值为数组的字段,往数组头部添加一个或多个值。或字段原为空,则创建该字段并设数组为传入值。

函数签名:

  1. function unshift(values: any[]): Command

示例代码

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

原文: https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-client-api/database/command.unshift.html