比如我有个值已经保存在mongodb中
[
1,
2,
5,
4,
3,
...
]
想更新成这样
[
1,
2,
3,
4,
5,
...
]
怎么搞效率最高, 假设这个数组的内容大约100k, 有上千元素
怪我咯2017-04-24 09:11:52
Take it out and sort it in the code, then set it back. There is no transaction for writing in mongo, and a large number of database operations are not recommended
大家讲道理2017-04-24 09:11:52
I think you can do this:
db.test.update({}, {$set:{"key.2":4, "key.3":3}})