0

目前正在使用它,但似乎没有加载。这只是需要一段时间还是我做错了什么?我的数据库在模数上是 3.0.3 而我的外壳是 3.2.1

db.itemtemplates.find().snapshot().forEach(
  function (e) {
    // update document, using its own properties
    e._id = e._id.str
    db.itemtemplates.save(e);
  }
)
4

1 回答 1

0

ObjectId将 an 转换为字符串的正确方法是toString(),请参阅文档

db.itemtemplates.find().snapshot().forEach(
  function (e) {
    // update document, using its own properties
    e._id = e._id.toString()
    db.itemtemplates.save(e);
  }
)
于 2016-02-15T19:07:31.577 回答