-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What would be the right type to pass an object? #625
Comments
The query looks just right, and your object will be inserted correctly as jsonb. Now for the typescript error, I don't know, and can't help since I don't use it :) |
Try casting …
return await sql`
INSERT INTO public.account (owner, email, contact, hashed_password)
VALUES (${owner}, ${email}, ${contact as SerializableParameter<object>}, crypt(${password}, gen_salt('md5')))
`;
… |
Is still throwing unfortunately: async function insertRow(table: Table, input: any) {
return table === "account"
? await sql`
INSERT INTO ${sql(table)} (owner, email, contact, hashed_password)
VALUES (${input.owner}, ${input.email}, ${input
.contact as postgres.SerializableParameter<
object
>}, crypt(${input.password}, gen_salt('md5')))
RETURNING *`
: await sql`
INSERT INTO ${sql(table)} ${sql(input)}
RETURNING *`;
}
|
I have the same problem and this works for me import { SerializableParameter } from 'https://deno.land/x/[email protected]/types/index.d.ts';
// fields of cache table
// key: text
// data: jsonb
async function add(key: string, data: unknown): Promise<boolean> {
await this.sql`INSERT INTO cache ("key", "data") VALUES (${key}, ${data as SerializableParameter})`;
// ... ...
} |
Hello,
in my table "account" the column "contact" is of the type
jsonb
. Using the following interface, I get an TS Error:I have two questions:
jsonb
?Thank you very much!
The text was updated successfully, but these errors were encountered: