The solution is to really create a Job using CloudCode. Here is an example in Javascript:
Parse.Cloud.job("airportMigration", function(request, status) {
Parse.Cloud.useMasterKey();
var recordsUpdated = 0;
var query = new Parse.Query("Airports");
query.doesNotExist("location");
query.each(function(airport) {
var location = {
latitude: airport.get("latitude_deg"),
longitude: airport.get("longitude_deg")
};
if (!location.latitude || !location.longitude) {
return Parse.Promise.error("There was an error.");
}
recordsUpdated += 1;
if (recordsUpdated % 100 === 0) {
status.message(recordsUpdated + " records updated.");
}
airport.set("location", new Parse.GeoPoint(location));
return airport.save();
}).then(function() {
status.success("Migration completed successfully.");
}, function(error) {
console.log(error);
status.error("Uh oh, something went wrong.");
});
});
source
share