Is it possible to do nested queries in cloud code?
I want to be able to do something like
var adList = [];
var query2 = new Parse.Query(\"QR\");
var
I think the below code might help someone,
var adList = [];
var query2 = new Parse.Query("QR");
var query = new Parse.Query("Campaigns");
query.equalTo("isFeatured", true);
query.find().then(function(results) {
var _ = require('underscore');
var promise = Parse.Promise.as();
_.each(results, function(resultObj) {
var ad = [];
ad.push(resultObj.get("Type")); //Adds "Type" to the ad array
ad.push(resultObj.id); //gets the objectID and appends it to the arrayy
//second INNER QUERY
query2.equalTo("abc", true);
adList.push(ad);
return query2.first().then(function(results) {
adList.push(5);
});
});
return promise;
}).then(function() {
response.success(adList);
}, function (error) {
response.error("Error "+error.message);
});