Advertisement

uniCloud项目 - 云数据库产品 - 更新文档集合 - update操作符

阅读量:

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'])
    
 })
    
    
    
    

Push机制设计与实现

在数组末尾添加元素 ,可接受单个数据项或整个数组作为输入

复制代码
 const dbCmd = db.command

    
  
    
 let res = await db.collection('comments').doc('comment-id').update({
    
   // users: dbCmd.push('aaa')
    
   users: dbCmd.push(['c', 'd'])
    
 })
    
    
    
    

Shift机制设计与实现

移除数组起始位置的元素

复制代码
 const dbC

全部评论 (0)

还没有任何评论哟~