-
Notifications
You must be signed in to change notification settings - Fork 470
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
Template literals function for use with callbacks #960
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions, I'm not entirely clear on how the callbacks are being accepted / executed in the template
method.
OK - I think I'm seeing a bit better what's going on here... is the problem that you can't do: request.query`some templated query`, cb because there's no way to pass the @willmorgan what are your thoughts on this? |
As I've got a bit of a better understanding of this, I'd think that the templating functions should probably be moved to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're doing tagged templates then why are we regressing from ES6 and doing callbacks?
Why not use async/await?
await request.query`select stuff from theplace`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fully sure if this is needed given above comment, but if I'm convinced, it needs to go into util as it has no business being on a request object.
There is still a lot of us trying to avoid promises as they are problematic: As for putting this in a 'utils' class, I don't think this would work since the template literal function needs to add input parameters to the request object. |
All good points, OK - I think I'm convinced - @willmorgan ? |
I'm not convinced at all if I'm honest. The rest of the library is async and in 5 years of writing async Node code, I've not suffered due to choosing a promise library that swallows exceptions. |
There is a Callbacks section in the readme, there is no indication that this is deprecated? Lot's of people find promises unnecessary and over engineered. I don't like to wrap all my async functions into stateful objects. |
Is there a tweak to this PR that would make this more palatable for you @willmorgan? I don't have a strong opinion on the naming, on other details or even on structuring this differently. I find template literals for SQL to be a great idea. Including this three statement function allows me to use them without monkeypatching. |
Not really, but thanks for asking 😄 I don't agree with the reasoning for callbacks in this particular use case, don't believe that furthering support of callbacks are the way forward with any modern JS library, and generally do not feel great about supporting yet another usage method. However for completeness and consistency, maybe this should be taken in. I would, however, move to deprecate callbacks in a later major release. |
Is anything holding this up? |
I need to find some time to be certain about this, I'm not entirely sure we can't use a |
fixes #957
This allows doing this: