javascript - Rate limiting parse.com background jobs -
I have some data in parse.com, which needs to be updated with background job. There are approximately 100 hundred rows, updating each row, 3 questions of pars API are used. Only 30 questions are allowed for each other, so when I start a job, only the first 9 rows are updated, and any user who accesses the system during other systems will get errors.
The easiest way to break the job is to update a line of 200 milliseconds or later, and the job only uses half the questions? This means that it will take about 20 seconds to run in the job, instead of just one second, but it is a fully acceptable business.
The structure of the code is almost the same:
pars .cloud.job ("UpdateData", function (request, status) {Parse.Cloud.useMasterKey (); ( New parse.Secoratives ("table")) .find (). Then (function (rows) {rows.forEach (function (line) {// some questions are here ... line .set (...). Ave ();}); status.success ();}, function (error) {status.error ();});}); I do not think I can easily use setTimeout or setInterval on this code (I'm sure if they are Permissions on parse.com cloud code) JS Anything sleep () or wait () .
To save all the objects in one bar and even for chain pars < Try the code> pars.office alert all as @ mbm29414, you will need other questions for your second look. Parse.Object.saveAll :
Parse.Cloud.job (
"update data", function (request, status) {parse.Cloud.useMasterKey (); (new parse security ("table")) .Find (). Then (function (lines) {var toSaveList = [] ; Var promise = new parse.promos (); rows.full (function (line) {// some questions are here ... line.Set (...); ... sevalist.push (line)}) ; Pars.ject .saveAll (toaveaveist, function) {promise.resolve ();}, function () {promise.reject ();}); return promis e;}). Then (function () {status.success ();}, F Kshn () {status.error ();});});
Comments
Post a Comment