command.mul

解释:数据库更新指令,用于将记录中的某个字段自乘指定的值。

代码示例

将 age 的值乘以 2:

  1. swan.cloud.init({
  2. env: 'envId'
  3. });
  4. const db = swan.cloud.database();
  5. const _ = db.command;
  6. db.collection('users')
  7. .doc('docId')
  8. .update({
  9. age: _.mul(2)
  10. })