复制文档从子文档中提升到文档

"sport": "NFL",
"team_id": 5,
"week_num": 6,
"meta": {
   .... more data ....,
   "season_year": 2013
}

变为
"sport": "NFL",
"team_id": 5,
"week_num": 6,
"season_year": 2013,
"meta": {
   .... more data ....,
   "season_year": 2013
}

db.yourCollection.find({}).forEach(function(doc) {
  doc.season_year = doc.meta.season_year;
  db.yourCollection.save(doc);
});

 

你可能感兴趣的:(复制)