Reputation: 750
How do I return the Sequence object from the private function when called from parse cloud function.
function getNextMemberId() {
var id = -1;
var Zseq = Parse.Object.extend("ZSeqMember");
var query = new Parse.Query(Zseq);
var IncObj;
query.get("lcnm8AZWFK", {
success: function (object) {
object.increment("Seq");
object.save(null,
{
success: function (object) { },
error: function (object, error) { return Parse.Promise.error(error); }
}
);
}, error: function (object, error) {
console.log(error);
return Parse.Promise.error(error);
}
});
//I want to return the Object, which contains "Seq" column.
}
Upvotes: 0
Views: 45
Reputation: 119041
You can't, because you don't have it when the function finishes, because the request to get it is asynchronous. You need to change getNextMemberId
so it includes a completion closure when can be used to 'return' the object once it's available.
Upvotes: 1