Created
August 26, 2015 22:50
-
-
Save lukas1994/7db26a33d564034bdeb5 to your computer and use it in GitHub Desktop.
migrate localeIdentifier field in Parse _Installation to new format
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
Parse.Cloud.job("localeIdentifierMigration", function(request, status) { | |
var modify = function(old) { | |
return old.replace(/_/g, "-").split("@")[0]; | |
}; | |
Parse.Cloud.useMasterKey(); | |
var query = new Parse.Query("_Installation"); | |
query.each(function(installation) { | |
var old = installation.get("localeIdentifier"); | |
if (old) { | |
installation.set("localeIdentifier", modify(old)); | |
} | |
return installation.save(); | |
}).then(function() { | |
status.success("Migration completed successfully."); | |
}, function(error) { | |
status.error("Something went wrong."); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment