BinarySolo
BinarySolo

Reputation: 101

Parse Cloud Code - Simple Query Doesn't Return Results

I'm a new user and novice coder trying to learn the basics of Cloud Code (please bear with me). I've been following online tutorials and I'm trying to replicate basic functionality to increment my knowledge and understanding.

I created a very simple class ("Students") with 2 objects: Screenshot

I just want to be able to run simple queries on the data to understand how queries work. However, using almost exactly the same code found in several online tutorials, I can't seem to get any results. I don't get errors, but I'm not able to get results when I create simple matches like query on "Name", "Alex":

Parse.Cloud.define("test", function(request, response) {
  var Student = Parse.Object.extend("Student");
  var query = new Parse.Query(Student);
  query.equalTo("Grade",95);
  query.find({
    success: function(results){
     console.log("received " + results.length + " result(s)");
    },
    error: function(error) {
     //error
     console.log("error: " + error);
    }
  });
  response.success("done");
});

After running this code, the only thing I see in my cloud log after the usual deploy and run text is this:

 Input: {}
 Result: done

This should be easy for most of you to troubleshoot. Just trying to learn this the hard way. Thanks!

Upvotes: 2

Views: 3990

Answers (1)

Put your "response.success("done");" in the "success: function(results)" that should fix it.

Upvotes: 4

Related Questions