MongoDB 更新(将项目列表插入数组) [英] MongoDB Update (Insert a List of Item to an Array)
本文介绍了MongoDB 更新(将项目列表插入数组)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 Mongo 的多行数组中添加几个项目.我该怎么做?
I want to add several items to arrays of several rows in Mongo. How can I do this?
我想从这个开始:
{'x': 'h', arr: [1,2,3] }
{'x': 'h', arr: [1,3] }
并添加数组 [6,8],其中 x 等于 'h':
and add the array [6,8], where the x is equal to 'h':
{'x': 'h', arr: [1,2,3,6,8] }
{'x': 'h', arr: [1,6,8] }
推荐答案
我认为您正在寻找的是 $pushAll 运算符.看看这里:
I think what you are looking for is the $pushAll operator. Take a look here:
http://docs.mongodb.org/manual/reference/operator/pushAll/#pushall
这篇关于MongoDB 更新(将项目列表插入数组)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文