Skip to content
New issue

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

how do I check the empty result #56

Open
bobchennan opened this issue Feb 24, 2012 · 2 comments
Open

how do I check the empty result #56

bobchennan opened this issue Feb 24, 2012 · 2 comments

Comments

@bobchennan
Copy link

I use query.on('row') to get the result.But if the result is empty,then how can I know it?
Because NodeJS is Asynchronous execution,I can't just write as this:
db.query("").on('row',function(r){
});
res.write('error');

So what I should do instead of?

@sidorares
Copy link
Owner

function getNumRowsInResult(db, sql, callback)
{
    var rowCount = 0;
    db.query(sql)
        .on('row', function() { rowCount++; })
        .on('end', function() { callback(rowCount); });
}

@bobchennan
Copy link
Author

Thanks a lot.

2012/2/25 Andrey Sidorov <
[email protected]

function getNumRowsInResult(db, sql, callback)
{
var rowCount = 0;
db.query(sql)
.on('row', function() { rowCount++; })
.on('end', function() { callback(rowCount); });
}


Reply to this email directly or view it on GitHub:

#56 (comment)

QQ:404692150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants