I'm trying to create an or query from an array of queries. I need to use an array because the amount of queries isn't fixed, it depends on a user input.
This is some sample code from parse.com to implement an or query.
var lotsOfWins = new Parse.Query("Player"); lotsOfWins.greaterThan("wins", 150); var fewWins = new Parse.Query("Player"); fewWins.lessThan("wins", 5); var mainQuery = Parse.Query.or(lotsOfWins, fewWins); mainQuery.find() .then(function(results) { // results contains a list of players that either have won a lot of games or won only a few games. }) .catch(function(error) { // There was an error. });
What I'm trying to do is
var orQueries = [];
Filling the array within a for-loop with Parse.Query Objects. Then I'm calling
var userQuery = new Parse.Query.or(orQueries);
which causes a internal server error:
"TypeError: A ParseQuery must be constructed with a ParseObject or class name.
How can I solve this issue and initialize the query with an array?
new. Parse.Query.or isn't a constructor, it's a method that returns a query for you. That being said you may still have a problem with passing an array instead of comma separated arguments.