We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi! I have the code:
var sys = require('sys'); var nStore = require('nstore/lib/nstore').extend(require('nstore/lib/nstore/query')()); var users = nStore.new('data/users.db', function (){ users.find({user: "alex", pass:"123"}, (function(err, results) { if(err) { sys.puts('not found...'); } else { sys.puts(results.creationix.room); } })); });
What I need is something like:
var sys = require('sys'); function routeToRoom(userId,passw){ var roomId=0; var nStore = require('nstore/lib/nstore').extend(require('nstore/lib/nstore/query')()); var users = nStore.new('data/users.db', function (){ users.find({user: userId, pass:passw}, (function(err, results) { if(err) { roomId=-1; } else { roomId=results.creationix.room; } })); }); return roomId; } sys.puts(routeToRoom("alex","123"));
But I get always: 0
I guess "return roomId;" is executed before that " roomId=results.creationix.room;" . Could someone help me whit this code? Thanks in advance!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi!
I have the code:
var sys = require('sys');
var nStore = require('nstore/lib/nstore').extend(require('nstore/lib/nstore/query')());
var users = nStore.new('data/users.db', function (){
users.find({user: "alex", pass:"123"}, (function(err, results) {
if(err) {
sys.puts('not found...');
}
else
{
sys.puts(results.creationix.room);
}
}));
});
What I need is something like:
var sys = require('sys');
function routeToRoom(userId,passw){
var roomId=0;
var nStore = require('nstore/lib/nstore').extend(require('nstore/lib/nstore/query')());
var users = nStore.new('data/users.db', function (){
users.find({user: userId, pass:passw}, (function(err, results) {
if(err) {
roomId=-1;
}
else
{
roomId=results.creationix.room;
}
}));
});
return roomId;
}
sys.puts(routeToRoom("alex","123"));
But I get always: 0
I guess "return roomId;" is executed before that " roomId=results.creationix.room;" . Could someone help me whit this code?
Thanks in advance!
The text was updated successfully, but these errors were encountered: