Skip to content

return results instead of callback #1054

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

Closed
TheColorRed opened this issue Apr 9, 2015 · 3 comments
Closed

return results instead of callback #1054

TheColorRed opened this issue Apr 9, 2015 · 3 comments
Assignees
Labels

Comments

@TheColorRed
Copy link

Is there a way to allow for results to be returned to a variable instead of posted through a callback?

var conn = mysql.createConnection({...});
var rows = conn.query("select * from my_table limit 10");

passing the results to a callback is nice, but not always needed and/or wanted.

@dougwilson
Copy link
Member

No; this is a limitation of Node.js. Network calls must always be async.

@TheColorRed
Copy link
Author

@dougwilson I believe that we can just use yield to solve that problem.

@dougwilson
Copy link
Member

Whatever we do has to work in Node.js 0.6, 0.8, 0.10, and 0.12. As far as I know, yield only exists is 0.12+, so it's not usable here. Someone more familiar with yield can chime in, or feel free to make a PR (our CI will validate it works in our supported Node.js environments).

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

No branches or pull requests

2 participants