Last active
August 31, 2017 08:57
-
-
Save deanmalan/fdc4d1cff7d95790382897f08f22a10e to your computer and use it in GitHub Desktop.
mm-394-script.js
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 collection = db.addressbook_2; | |
collection.find({'fields.verificationChannel': 'iOS'}).forEach(function(doc) { | |
if (doc.fields && (!doc.fields.latitude || !doc.fields.longitude)) { | |
collection.update( | |
{_id : doc._id}, | |
{$set: { "fields.requiresVerification": "true"}} | |
); | |
} else if (doc.fields && ((doc.fields.latitude && doc.fields.latitude % 1 == 0) || (doc.fields.longitude && doc.fields.longitude == 0))) { | |
collection.update( | |
{_id : doc._id}, | |
{$set: { "fields.requiresVerification": "true"}} | |
); | |
} | |
}); | |
print("Verifying"); | |
var remaining_tasks = 0; | |
collection.find({'fields.verificationChannel': 'iOS'}).forEach(function(doc) { | |
if (doc.fields && (!doc.fields.latitude || !doc.fields.longitude) && doc.fields.requiresVerification !== "true") { | |
remaining_tasks = remaining_tasks + 1; | |
} else if (doc.fields && ((doc.fields.latitude && doc.fields.latitude % 1 == 0) || (doc.fields.longitude && doc.fields.longitude == 0)) && doc.fields.requiresVerification !== "true") { | |
remaining_tasks = remaining_tasks + 1; | |
} | |
}); | |
if (remaining_tasks == 0){ | |
print("Migration was successful"); | |
} | |
else { | |
print("Migration has failed"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍