UniCloud 自增与自减
自增
const dbCmd = db.command
let res = await db.collection('user').where({
_id: 'my-doc-id'
}).update({
view:dbCmd.inc(1) //@param 自增1
})
const dbCmd = db.command
let res = await db.collection('user').where({
_id: 'my-doc-id'
}).update({
view:dbCmd.inc(5) //@param 自增5
})
自减
const dbCmd = db.command
let res = await db.collection('user').where({
_id:'my-doc-id'
}).update({
view:dbCmd.dec(1) //@param 自减1
})
const dbCmd = db.command
let res = await db.collection('user').where({
_id:'my-doc-id'
}).update({
view:dbCmd.dec(5) //@param 自减5
})