Created
December 22, 2017 03:35
-
-
Save novalagung/b8632f616475bf4e27e1bb525ef8d113 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var portfolioMaster = db.getCollection('RAW_CORE_PROJECT').aggregate([ | |
{ $group: { | |
_id: { | |
ProgramID: "$PROGRAM_ID", | |
Portfolio: "$PORTFOLIO_NAME", | |
} | |
} }, | |
{ $project: { | |
ProgramID: "$_id.ProgramID", | |
Portfolio: "$_id.Portfolio", | |
_id: 0 | |
} } | |
]).toArray() | |
db.getCollection('Initiative').find({ InitiativeType: "ITO" }).forEach(function (d) { | |
var masterFound = portfolioMaster.find(function (g) { return g.ProgramID == d.ClarityId }) | |
if (typeof masterFound !== 'undefined') { | |
d.Portofolio = masterFound.Portfolio // haruse portfolio, typo, ben kah | |
db.getCollection('Initiative').save(d) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment