Inserting multiple rows with a single query via the sql.file method.
#562
virtuallyunknown
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings.
I really like this library, however, one thing I don't like is using tagged templates, because that way you can't have auto-formatting and code-completions/suggestions in VSCode. So the way I go about this instead is to create an
.sqlfile next to my.tsfile, then usesql.file(...), for example:This works, but what if you wanted to insert multiple rows at the same time? The documentation says to use an array of values, and sure enough it works with the tagged template, however
sql.fileno longer works. Example:I've done some debugging trying to replicate the
argsthat the tagged version sends to the database, but I couldn't get it right. I think the library does some extra work behind the scenes to modify the statement to match the amount of rows you pass in, however the file method doesn't.So with all of that in mind, I do have two quick questions:
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions