You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constSQL=require("sql-template-strings");constexampleQuery="SELECT * FROM example_table";SQL(exampleQuery);//returns: SQLStatement { strings: 'SELECT * FROM example_table', values: [] }
I love your package and have been using it extensively in my own project, but was having trouble converting some constants into SQL objects without using append. I figured out that calling SQL as a function and passing in a string variable does the trick. I would be happy to directly edit the README and submit a pull request if that works best.
Also I was wondering if it would be possible to create a new feature that allows the user to pass in an array of strings and get a complete SQL object in return, for example:
constSQL=require("sql-template-strings");SQL(["SELECT * FROM"," example_table"]).text;//returns: 'SELECT * FROM example_table'//right now it's inserting a positional parameter between the strings
I would be happy to work on it and submit a pull request as well if that works best
The text was updated successfully, but these errors were encountered:
My apologies for not being clear, there are no issues with the current command, I was suggesting an extension of functionality in the case where the developer may want to store certain query strings and variables and finds repeated calls to append inconvenient. For example
constcommand='SELECT ';constformatted_cols=' to_char(date as 'yyyy-mm-dd') AS date'consttable=' FROM example_table';//more convenient:SQL(command+formatted_cols+table);//workaround:SQL``.append(command).append(formatted_cols).append(table);
I love your package and have been using it extensively in my own project, but was having trouble converting some constants into SQL objects without using append. I figured out that calling SQL as a function and passing in a string variable does the trick. I would be happy to directly edit the README and submit a pull request if that works best.
Also I was wondering if it would be possible to create a new feature that allows the user to pass in an array of strings and get a complete SQL object in return, for example:
I would be happy to work on it and submit a pull request as well if that works best
The text was updated successfully, but these errors were encountered: