db.command.shift

更新指令,对一个值为数组的字段,将数组头部元素删除。

函数签名:

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

示例代码

  1. const cloud = require('wx-server-sdk')
  2. cloud.init()
  3. const db = cloud.database()
  4. const _ = db.command
  5. exports.main = async (event, context) => {
  6. try {
  7. return await db.collection('todos').doc('doc-id').update({
  8. data: {
  9. tags: _.shift()
  10. }
  11. })
  12. } catch(e) {
  13. console.error(e)
  14. }
  15. }

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