本文介绍了MongoDB的更新(插入项目的List数组)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要几个项目添加到蒙戈几排的阵列。我怎样才能做到这一点?
我要开始这个:
{'X':'H',编曲:[1,2,3]}
{'X':'H',编曲:[1,3]}
和添加数组[6,8],其中x等于H:
{'X':'H',编曲:[1,2,3,6,8]}
{'X':'H',编曲:[1,6,8]}
解决方案
我想你正在寻找的是$ pushAll运营商。看看这里:
http://docs.mongodb.org/manual/reference/operator/pushAll/#pushall
I want to add several items to arrays of several rows in Mongo. How can I do this?
I want to start with this:
{'x': 'h', arr: [1,2,3] }
{'x': 'h', arr: [1,3] }
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] }
解决方案
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的更新(插入项目的List数组)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!