db.command.remove

更新指令。用于表示删除某个字段。

函数签名:

  1. function remove(): Command

示例代码

删除 style 字段:

  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('todo-id').update({
  8. data: {
  9. style: _.remove()
  10. }
  11. })
  12. } catch(e) {
  13. console.error(e)
  14. }
  15. }

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