2016-02-15 98 views
0

當前正在使用此操作,但似乎未加載。這是否需要一段時間,或者我做錯了什麼?我的數據庫是模量是3.0.3,而我的殼是3.2.1將文檔_id從對象更改爲字符串?

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

回答

0

正確的方法來轉換一個ObjectId到字符串是toString(),看到documentation

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

謝謝。這工作。 – Daniel

相關問題