1. unshift
向数组头部添加元素,支持传入单个元素或数组
const dbCmd = db.command
let res = await db.collection('comments').doc('comment-id').update({
// users: dbCmd.push('aaa')
users: dbCmd.unshift(['c', 'd'])
})
2. push
向数组尾部追加元素,支持传入单个元素或数组
const dbCmd = db.command
let res = await db.collection('comments').doc('comment-id').update({
// users: dbCmd.push('aaa')
users: dbCmd.push(['c', 'd'])
})
3. shift
删除数组头部元素
const dbCmd = db.command
let res = await db.collection('comments').doc('comment-id').update({
users: dbCmd.shift()
})
4. pop
删除数组尾部元素
const dbCmd = db.command
let res = await db.collection('com