微信小程序云开发API 更新指令


当前第2页 返回上一页

函数签名:

function mul(value: number): Command

示例代码

将一个 todo 的进度乘 2:

const _ = db.command
db.collection('todos').doc('todo-id').update({
  data: {
    progress: _.mul(2)
  }
})

db.command.push

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

函数签名:

function push(values: any[]): Command

示例代码

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

db.command.pop

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

函数签名:

function pop(values: any[]): Command

示例代码

const _ = db.command
db.collection('todos').doc('doc-id').update({
  data: {
    tags: _.pop()
  }
})

db.command.shift

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

函数签名:

function shift(values: any[]): Command

示例代码

const _ = db.command
db.collection('todos').doc('doc-id').update({
  data: {
    tags: _.shift()
  }
})

db.command.unshift

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

函数签名:

function unshift(values: any[]): Command

示例代码

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

标签:微信小程序

返回前面的内容

相关阅读 >>

微信小程序 getvisitdistribution

微信小程序api 关闭所有页面

微信小程序 工具库类threejs

小程序 api

微信小程序工具 体验评分

微信小程序云开发服务端数据库api 在集合上新增记录

微信小程序 运维中心realtimelogsearch

微信小程序 运力方使用oncancelauth

微信小程序 图片高清化能力

sdk数据库 database发起事务

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...