MongoDB更改Array-Element的索引

时间:2015-01-26 03:18:30

标签: javascript mongodb mongodb-query

我有一个MongoDB文档,如下所示:

root
   _id: "some-mongo-id",
   title: "MyTitle",
   text:  "My Text",
   contents: [
      0: ...some content object ...,
      1: ...some other object ...,
      2: ...some third object...
      ...
      11: ... some object ...
   ]

我现在想要更改例如将root.contents [2]的索引设置为例如7.所以我想理想地根据旧索引和内容应该去的新位置求助数组。

最好的方法是什么?

0 个答案:

没有答案