SQL param
This guide assumes familiarity with:
sql.param
lets you define a parameter with a custom type accepted by the CockroachDB client
By default, passing 10
will generate this SQL and parameters array
await sql`select * from ${sql.identifier("users")} where ${sql.identifier("id")} = ${10};`
select * from "users" where "id" = $1::int4;
-- params: [10]
You can use sql.param
to override this behavior
await sql`select * from ${sql.identifier("users")}
where ${sql.identifier("id")} = ${sql.param(10, 'int8')};`
select * from "users" where "id" = $1::int8;
-- params: [10]