Adding arguments to rawQueryTyped with MySql

The docs mention that you can add arguments to rawQueryTyped queries https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/typedsql#passing-arguments-to-typedsql-queries
SELECT id, name, age
FROM users
WHERE age > ? AND age < ?
SELECT id, name, age
FROM users
WHERE age > ? AND age < ?
I'm pretty inexperienced with raw sql, so I have a few questions: 1. The docs show the example of getUsersByAge(minAge, maxAge). How exactly are the variables minAge, maxAge mapped to the positional placeholders? is it based on the order that the placeholders appear? 2. What if I want to use a parameter multiple times? Will I have to pass in the parameter multiple times? 3. Is there a way to pass in the parameter, set it to a variable name in the SQL script, and reuse the variable name?
Writing Type-safe SQL with TypedSQL and Prisma Client | Prisma Docu...
Learn how to use TypedSQL to write fully type-safe SQL queries that are compatible with any SQL console and Prisma Client.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server