I’d like to run two queries to the db – or whatever parse.com uses – consecutively.
So i have:
var query = Parse.Query("table1");
....
var query2 = Parse.Query("table2");
...
The first query is just checking some stuff to make sure that everything is ok with the request – that the device version is right etc.
The second query is the actual point of the whole exercise.
Because the first query is being asked for pretty much all the functions i’m using, I’d like to keep it separate. I don’t really want to keep defining it for each function, and then sub-calling the second query – that’s repetitive and stupid.
Is there some elegant way – ie not whiling on a boolean and setting the boolean to true in the first queries’ success method – to run the two queries consecutively?
I broke the queries up into two functions,
Then from within the success of function1() I call function2 – or rather, I call a given parameter (assuming it isn’t undefined!)
And now I have a reusable component that I can use as I see fit!
BONUS: what if function2 requires paramters?
So! In the main function that calls both these two, we have:
with function1 defined as above.