简体   繁体   中英

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).

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.
}
});

The answer is something like:

document.write(list[0].get('Student'));

so it's the getters and setters part in JS.

Thanks a lot @nawaz-cloudboost.io !!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM