0
如何使用Mongoid进行批量更新?使用Mongoid进行批量更新
具体而言,将一个现有字段复制到另一个相同的文档。
Product.collection.command("db.products.find(
{gender : { $ne : null } }
).forEach(function(doc) {
doc.archive_gender = doc.gender;
doc.gender = null;
db.products.save(doc);
})"
)
干杯, Khoa。
可能重复的[Mongoid Batch Update/Upsert Alternative?](http://stackoverflow.com/questions/25550690/mongoid-batch-update-upsert-alternative) – akostadinov