Placeholders in inserting: db.insert().values(placeholder('example'))
Hey, how do I add placeholders inside the values of an insert prepare statement? I get an typeerror when I do so.
3 Replies
My current code that results in a typeerror is the following:
I have no issue using placeholders in delete, and select statements, only in this case.
If this is not supported, how can I implement this in something like Vercel Functions?
same issue here i would love to hear the answer to this issue
ok found the answer this worked for me
db.insert(users)
.values({
email: sql.placeholder('email'),
name: sql.placeholder('name'),
emailVerified: sql.placeholder('emailVerified'),
image: sql.placeholder('image'),
active: sql.placeholder('active'),
roles: sql.placeholder('roles'),
company: sql.placeholder('company')
})
.onConflictDoNothing()
.prepare('insert_users')
I don't know that you're supposed to use placeholders for the whole values object or array