0
我有數據集作爲如何在MongoDB中更新高效的收集字段?
{"id":1,"Timestamp":"Mon, 11 May 2015 07:57:46 GMT","brand":"a"}
{"id":2,"Timestamp":"Mon, 11 May 2015 08:57:46 GMT","brand":"a"}
數據的預期結果是
{"id":1,"Timestamp":ISODate("2015-05-11T07:57:46Z"),"brand":"a"}
{"id":2,"Timestamp":ISODate("2015-05-11T08:57:46Z"),"brand":"b"}
這意味着我想從字符串中的每個行修改時間戳ISODate 我當前的代碼是
db.tmpAll.find().forEach(
function (a) {
a.Timestamp = new Date(a.Timestamp);
db.tmpAll2.insert(a);
}
);
它運行成功,但運行代碼需要幾分鐘時間,它需要創建一個新的集合。有沒有有效的方法來做到這一點?