Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
499 B
4
Indexable
Never
db.global_config.aggregate([
  {
    $lookup: {
      from: "country_region",
      localField: "CountryCode",
      foreignField: "CountryCode",
      as: "countryInfo"
    }
  },
  {
    $unwind: "$countryInfo"
  },
  {
    $set: {
      RegionCode: "$countryInfo.RegionCode"
    }
  },
  {
    $project: {
      countryInfo: 0
    }
  }
]).forEach(function(doc) {
  db.global_config.updateOne(
    { _id: doc._id },
    { $set: { RegionCode: doc.RegionCode } }
  );
});
Leave a Comment