简体   繁体   中英

how to get complete details of user from parse cloud and use those in background jobs function

This is my code I am getting number of users and objects as "result [object Object],[object Object],[object Object]" but I want to fetch the details of each object and want to use those details Please help me how to fetch the user details

 Parse.Cloud.job("findAll", function(request, status) { // var comments= Parse.Cloud.run("makeCall",{success: function(object) {response.success(object);}}); Parse.Cloud.useMasterKey() var result = []; var processCallback = function(res) { result = result.concat(res); if (res.length === 1000) { process(res[res.length-1].id); return; } // do something about the result, result is all the object you needed. //status.success("final length " + result.length); //status.success("final result " + result); } var process = function(skip) { var query = new Parse.Query(Parse.User); if (skip) { console.log("in if"); query.greaterThan("objectId", skip); } query.limit(1000); //query.contains("objectId",request.params.objectId); query.find().then(function querySuccess(res) { processCallback(res); status.success("result " + res('username')); }, function queryFailed(reason) { status.error("query unsuccessful, length of result " + result.length + ", error:" + error.code + " " + error.message); }); } process(false); }); 

The line status.success("result " + res('username')); is concatenating a string with an object, which will call toString() on the object before the concatenation can be done.

If you want to pass a string to success , serialize the object to JSON:

status.success("result " + JSON.stringify(res('username')));

If you want to pass the result object to success , just pass the object without the string concatenation:

status.success(res('username'));

Below is a working example to illustrate the difference among the three approaches.

 var result = { color: 'blue', shape: 'square' }; //String concatenation with object log('Result ' + result); //String concatenation with JSON log('Result ' + JSON.stringify(result)); //Object log(result); //Log function for demonstration purposes function log (o) { var e = document.createElement('pre'); e.innerHTML = JSON.stringify(o, null, ' '); document.body.appendChild(e); } 

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