javascript - Parse background job - Parse.Query.each() promise behavior -
thanks stopping help!
i have background job have rewrite using parse.query.each(), have several thousand objects, , number continue grow on product's life cycle. here's link parse.query.each()'s documentation.
i have query through 2 different sets of objects 2 custom classes, , depending on data, modify array of objects of third custom class. trying use promises perform both queries save array of objects. however, first query returns error, , trying access error message throwing error since says error undefined. unable debug code, can't relevant error message figure out why first query not succeeding.
here's code setup, i'm trying use promises in conjunction query.each:
//set queries query1.each ( function( object1 ) { {//do stuff modifying arrayofobject3s} } ).then ( function( results ) { return query2.each ( function( object2 ) {//do more stuff modifying arrayofobject3s} ); }, function( error ) { //this line i'm getting error at, saying "cannot read property 'message' of undefined at..." status.error("there error while performing query1: " + error.message); } ).then ( function( results ) { return parse.object.saveall( arrayofobject3s); }, function( error ) { status.error("there error performing query2: " + error.message) } ).then ( function( arrayofobject3s ) { status.success("performed queries , saved objects!"); }, function( error ) { status.error("there error while saving objects: " + error.message); } );
i'm misunderstanding how use query.each along parse promises, because job fails error saying "cannot read property 'message' of undefined at..." , gives line number of first function( error )
in first .then()
block. have tried both see above, , 1 without results
in first function both of first 2 .then()
blocks, getting same error.
if have suggestions set properly, please let me know. novice these promises, , first time trying use query.each().
Comments
Post a Comment