-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.4.2
-
Component/s: None
-
None
-
Environment:Ubuntu 12.10
-
Linux
-
This statement did not preserve the _id's of the original (new ones were created):
// move posts to the attic
var attic = connect("localhost:27017/nomic_attic");
db.Post.find(
).sort({_id:-1}).forEach( function(vouchPost) {
attic.VouchPost.save(vouchPost);
});
I had to do this workaround to get the _id to remain unchanged in the new collection:
// move posts to the attic
var attic = connect("localhost:27017/nomic_attic");
db.Post.find(
).sort({_id:-1}).forEach( function(vouchPost) {
var copy = {};
for (var key in vouchPost) {
if (vouchPost.hasOwnProperty(key))
}
attic.VouchPost.save(copy);
});
- duplicates
-
SERVER-9385 Shell ignores modified object's "_id" field
- Closed