As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
testCollection.find() is an asynchronous call to the database. In your example, the find method is executed asynchronously, and then the logger methods are immediately executed before the find callback is invoked. If you move the logger statements at the end of this code to within the callback (after the for loop) it should resolve this issue.
s
sandip_armal
said
about 9 years ago
I tried with awaitdata but still its not seems to be working.... and do I need to set it to response in find itself ?
I got your point of moving logger statement into find function itself, but actually I was asking about whether I need to set data to response.body in find itself ? so that I can receive it ?
M
Michael
said
about 9 years ago
If you want to send it back to the client, then yes, you need to set response.body and response.complete in the callback itself.
s
sandip_armal
said
about 9 years ago
Hi @Michael I tried to print response use Logger then i am able to see the response in collection hook but i am getting null on my client.
sandip_armal
I am using below code to find records from some collection.
var tests = {};
testCollection.find({testid: testNumber}, { sort:{timestamp: 1 },
function( err, results) {
if(err) {
logger.error("Unable to proceed");
}
for(var i = 0; i
tests[i] = results[i].name;
}
});
logger.info("Available Tests");
logger.info(tests);
So I am always getting tests printed as {};
Why the properties are not being set to tests in for loop ?