Want to assign to the variable x value found result, how to do it. Thank you.
var x;
someModel.findQ({"name":"John"}.then(function(result){
result// here i have my object, how i can make this in var x ?
});
You can't put it in var x
*, that's how JavaScript concurrency works. See my answer here on a broader take on the topic.
someModel.findQ({"name":"John"}.then(function(result){
// use result here
});
You don't have to nest though, since promises chain
someModel.findQ({"name":"John"}.then(function(result){
// use result here
return someOtherModel.findQ({"name" : result.name });
}).then(function(obj){
// you can access the return result of someOtherModel here
});
* unless you're willing to try experimental features like generators that aren't in node stable yet.