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
-
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
.sql
file next to my.ts
file, 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.file
no longer works. Example:I've done some debugging trying to replicate the
args
that 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