Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudboost. Beginner. How to display the query example?

This is the Cloudboost query example:

var query = new CB.CloudQuery("Student");
query.equalTo('age', 21); //find all Students who age is 21
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});

My question is: How do i display the content of query? When i do it like this

document.write(query);

i get

[object, Object] 

If i look in the forum it should be solved with

document.write(JSON.stringify(list));

But that doesn't work. I'm in Monaca (Phonegap).

like image 386
Remzo Avatar asked Aug 08 '16 08:08

Remzo


1 Answers

Query.find function take in an object which contains two callbacks, a success function and an error function. Success function returns a list of CloudObjects and that's what you need. Here's the sample code below :

var query = new CB.CloudQuery("Student");
query.equalTo('age', 21); //find all Students who age is 21
query.find({
success: function(list){
   console.log(list); //here's the result of the query
},
error: function(err) {
//Error in retrieving the data.
}
});
like image 165
Nawaz Dhandala Avatar answered Oct 26 '22 19:10

Nawaz Dhandala