Skip to content

Commit 1669fc4

Browse files
committed
Regenerate examples with updated postgres driver codegen
1 parent 4c56594 commit 1669fc4

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

examples/bun-postgres/src/db/query_sql.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
// Code generated by sqlc. DO NOT EDIT.
22

3-
import { Sql } from "postgres";
3+
import type { Sql as SQL } from "postgres";
44

55
export const getAuthorQuery = `-- name: GetAuthor :one
66
SELECT id, name, bio FROM authors
77
WHERE id = $1 LIMIT 1`;
88

99
export interface GetAuthorArgs {
10-
id: string;
10+
id: number;
1111
}
1212

1313
export interface GetAuthorRow {
14-
id: string;
14+
id: number;
1515
name: string;
1616
bio: string | null;
1717
}
1818

1919
export type GetAuthorRowValues = [
20-
string,
20+
number,
2121
string,
2222
string | null
2323
];
2424

25-
export async function getAuthor(sql: Sql, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
26-
const rows = await sql.unsafe(getAuthorQuery, [args.id]).values();
25+
export async function getAuthor(sql: SQL, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
26+
const rows = await sql.unsafe(getAuthorQuery, [args.id]).values() as GetAuthorRowValues[];
2727
if (rows.length !== 1) {
2828
return null;
2929
}
@@ -32,7 +32,7 @@ export async function getAuthor(sql: Sql, args: GetAuthorArgs): Promise<GetAutho
3232
return null;
3333
}
3434
return {
35-
id: row[0],
35+
id: Number(row[0]),
3636
name: row[1],
3737
bio: row[2]
3838
};
@@ -43,20 +43,20 @@ SELECT id, name, bio FROM authors
4343
ORDER BY name`;
4444

4545
export interface ListAuthorsRow {
46-
id: string;
46+
id: number;
4747
name: string;
4848
bio: string | null;
4949
}
5050

5151
export type ListAuthorsRowValues = [
52-
string,
52+
number,
5353
string,
5454
string | null
5555
];
5656

57-
export async function listAuthors(sql: Sql): Promise<ListAuthorsRow[]> {
58-
return (await sql.unsafe(listAuthorsQuery, []).values()).map((row: any[]) => ({
59-
id: row[0],
57+
export async function listAuthors(sql: SQL): Promise<ListAuthorsRow[]> {
58+
return (await sql.unsafe(listAuthorsQuery, []).values() as ListAuthorsRowValues[]).map(row => ({
59+
id: Number(row[0]),
6060
name: row[1],
6161
bio: row[2]
6262
}));
@@ -76,19 +76,19 @@ export interface CreateAuthorArgs {
7676
}
7777

7878
export interface CreateAuthorRow {
79-
id: string;
79+
id: number;
8080
name: string;
8181
bio: string | null;
8282
}
8383

8484
export type CreateAuthorRowValues = [
85-
string,
85+
number,
8686
string,
8787
string | null
8888
];
8989

90-
export async function createAuthor(sql: Sql, args: CreateAuthorArgs): Promise<CreateAuthorRow | null> {
91-
const rows = await sql.unsafe(createAuthorQuery, [args.name, args.bio]).values();
90+
export async function createAuthor(sql: SQL, args: CreateAuthorArgs): Promise<CreateAuthorRow | null> {
91+
const rows = await sql.unsafe(createAuthorQuery, [args.name, args.bio]).values() as CreateAuthorRowValues[];
9292
if (rows.length !== 1) {
9393
return null;
9494
}
@@ -97,7 +97,7 @@ export async function createAuthor(sql: Sql, args: CreateAuthorArgs): Promise<Cr
9797
return null;
9898
}
9999
return {
100-
id: row[0],
100+
id: Number(row[0]),
101101
name: row[1],
102102
bio: row[2]
103103
};
@@ -108,10 +108,10 @@ DELETE FROM authors
108108
WHERE id = $1`;
109109

110110
export interface DeleteAuthorArgs {
111-
id: string;
111+
id: number;
112112
}
113113

114-
export async function deleteAuthor(sql: Sql, args: DeleteAuthorArgs): Promise<void> {
114+
export async function deleteAuthor(sql: SQL, args: DeleteAuthorArgs): Promise<void> {
115115
await sql.unsafe(deleteAuthorQuery, [args.id]);
116116
}
117117

examples/node-postgres/src/db/query_sql.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
// Code generated by sqlc. DO NOT EDIT.
22

3-
import { Sql } from "postgres";
3+
import type { Sql as SQL } from "postgres";
44

55
export const getAuthorQuery = `-- name: GetAuthor :one
66
SELECT id, name, bio FROM authors
77
WHERE id = $1 LIMIT 1`;
88

99
export interface GetAuthorArgs {
10-
id: string;
10+
id: number;
1111
}
1212

1313
export interface GetAuthorRow {
14-
id: string;
14+
id: number;
1515
name: string;
1616
bio: string | null;
1717
}
1818

1919
export type GetAuthorRowValues = [
20-
string,
20+
number,
2121
string,
2222
string | null
2323
];
2424

25-
export async function getAuthor(sql: Sql, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
26-
const rows = await sql.unsafe(getAuthorQuery, [args.id]).values();
25+
export async function getAuthor(sql: SQL, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
26+
const rows = await sql.unsafe(getAuthorQuery, [args.id]).values() as GetAuthorRowValues[];
2727
if (rows.length !== 1) {
2828
return null;
2929
}
@@ -32,7 +32,7 @@ export async function getAuthor(sql: Sql, args: GetAuthorArgs): Promise<GetAutho
3232
return null;
3333
}
3434
return {
35-
id: row[0],
35+
id: Number(row[0]),
3636
name: row[1],
3737
bio: row[2]
3838
};
@@ -43,20 +43,20 @@ SELECT id, name, bio FROM authors
4343
ORDER BY name`;
4444

4545
export interface ListAuthorsRow {
46-
id: string;
46+
id: number;
4747
name: string;
4848
bio: string | null;
4949
}
5050

5151
export type ListAuthorsRowValues = [
52-
string,
52+
number,
5353
string,
5454
string | null
5555
];
5656

57-
export async function listAuthors(sql: Sql): Promise<ListAuthorsRow[]> {
58-
return (await sql.unsafe(listAuthorsQuery, []).values()).map((row: any[]) => ({
59-
id: row[0],
57+
export async function listAuthors(sql: SQL): Promise<ListAuthorsRow[]> {
58+
return (await sql.unsafe(listAuthorsQuery, []).values() as ListAuthorsRowValues[]).map(row => ({
59+
id: Number(row[0]),
6060
name: row[1],
6161
bio: row[2]
6262
}));
@@ -76,19 +76,19 @@ export interface CreateAuthorArgs {
7676
}
7777

7878
export interface CreateAuthorRow {
79-
id: string;
79+
id: number;
8080
name: string;
8181
bio: string | null;
8282
}
8383

8484
export type CreateAuthorRowValues = [
85-
string,
85+
number,
8686
string,
8787
string | null
8888
];
8989

90-
export async function createAuthor(sql: Sql, args: CreateAuthorArgs): Promise<CreateAuthorRow | null> {
91-
const rows = await sql.unsafe(createAuthorQuery, [args.name, args.bio]).values();
90+
export async function createAuthor(sql: SQL, args: CreateAuthorArgs): Promise<CreateAuthorRow | null> {
91+
const rows = await sql.unsafe(createAuthorQuery, [args.name, args.bio]).values() as CreateAuthorRowValues[];
9292
if (rows.length !== 1) {
9393
return null;
9494
}
@@ -97,7 +97,7 @@ export async function createAuthor(sql: Sql, args: CreateAuthorArgs): Promise<Cr
9797
return null;
9898
}
9999
return {
100-
id: row[0],
100+
id: Number(row[0]),
101101
name: row[1],
102102
bio: row[2]
103103
};
@@ -108,10 +108,10 @@ DELETE FROM authors
108108
WHERE id = $1`;
109109

110110
export interface DeleteAuthorArgs {
111-
id: string;
111+
id: number;
112112
}
113113

114-
export async function deleteAuthor(sql: Sql, args: DeleteAuthorArgs): Promise<void> {
114+
export async function deleteAuthor(sql: SQL, args: DeleteAuthorArgs): Promise<void> {
115115
await sql.unsafe(deleteAuthorQuery, [args.id]);
116116
}
117117

0 commit comments

Comments
 (0)