Skip to content

Commit 7ceccce

Browse files
committed
fixes
1 parent 4eedc22 commit 7ceccce

34 files changed

Lines changed: 121 additions & 91 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ npm install typegres pg
1919
```
2020

2121
```typescript
22-
import { typegres, Int8, Text, expose } from "typegres";
22+
import { typegres, expose } from "typegres";
23+
import { Int8, Text } from "typegres/postgres";
2324

2425
const { db, conn } = await typegres({
2526
type: "pg",

examples/basic/src/tables/collars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Int8, Text } from "typegres";
1+
import { Int8, Text } from "typegres/postgres";
22
import { db } from "../db";
33
import { Dogs } from "./dogs";
44

examples/basic/src/tables/dogs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Int8, Text, Timestamptz, sql } from "typegres";
1+
import { sql } from "typegres";
2+
import { Int8, Text, Timestamptz } from "typegres/postgres";
23
import { db } from "../db";
34
import { Teams } from "./teams";
45
import { Collars } from "./collars";

examples/basic/src/tables/microchips.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Int8, Text } from "typegres";
1+
import { Int8, Text } from "typegres/postgres";
22
import { db } from "../db";
33
import { Dogs } from "./dogs";
44

examples/basic/src/tables/teams.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Int8, Text } from "typegres";
1+
import { Int8, Text } from "typegres/postgres";
22
import { db } from "../db";
33
import { Dogs } from "./dogs";
44

examples/basic/src/tables/toys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Int8, Text } from "typegres";
1+
import { Int8, Text } from "typegres/postgres";
22
import { db } from "../db";
33
import { Dogs } from "./dogs";
44

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@
1313
"import": "./dist/config.mjs",
1414
"types": "./dist/config.d.mts"
1515
},
16-
"./types": {
17-
"import": "./dist/types/index.mjs",
18-
"types": "./dist/types/index.d.mts"
19-
},
2016
"./sql-builder": {
2117
"import": "./dist/builder/sql.mjs",
2218
"types": "./dist/builder/sql.d.mts"
2319
},
20+
"./postgres": {
21+
"import": "./dist/types/postgres/index.mjs",
22+
"types": "./dist/types/postgres/index.d.mts"
23+
},
24+
"./sqlite": {
25+
"import": "./dist/types/sqlite/index.mjs",
26+
"types": "./dist/types/sqlite/index.d.mts"
27+
},
2428
"./exoeval": {
2529
"import": "./dist/exoeval/index.mjs",
2630
"types": "./dist/exoeval/index.d.mts"

site/package-lock.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/demo/demo.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
2020
const user = await api.currentUser();
2121
return user.orders()
2222
.select(({ orders }) => ({ id: orders.id, org: orders.organization_id }))
23-
.execute(api.db);
23+
.execute(api.conn);
2424
});
2525
expect(alice.length).toBeGreaterThan(0);
2626
expect(new Set(alice.map((r) => r.org))).toEqual(new Set(["1"]));
@@ -30,7 +30,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
3030
const user = await api.currentUser();
3131
return user.orders()
3232
.select(({ orders }) => ({ id: orders.id, org: orders.organization_id }))
33-
.execute(api.db);
33+
.execute(api.conn);
3434
});
3535
expect(dave.length).toBeGreaterThan(0);
3636
expect(new Set(dave.map((r) => r.org))).toEqual(new Set(["2"]));
@@ -42,7 +42,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
4242
return user.orders()
4343
.where(({ orders }) => orders.status.in("packed", "shipped"))
4444
.select(({ orders }) => ({ id: orders.id, status: orders.status }))
45-
.execute(api.db);
45+
.execute(api.conn);
4646
});
4747
for (const row of result) {
4848
expect(["packed", "shipped"]).toContain(row.status);
@@ -57,7 +57,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
5757
id: orders.id,
5858
customer: orders.customer().select(({ customers }) => ({ name: customers.name })).scalar(),
5959
}))
60-
.execute(api.db);
60+
.execute(api.conn);
6161
});
6262
expect(result.length).toBeGreaterThan(0);
6363
for (const row of result) {
@@ -74,7 +74,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
7474
status: orders.status,
7575
count: orders.id.count(),
7676
}))
77-
.execute(api.db);
77+
.execute(api.conn);
7878
});
7979
expect(result.length).toBeGreaterThan(0);
8080
for (const row of result) {
@@ -90,7 +90,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
9090
return user.orders()
9191
.where(({ orders }) => orders.status["="]("draft"))
9292
.select(({ orders }) => ({ id: orders.id }))
93-
.live(api.db);
93+
.live(api.conn);
9494
});
9595
const it = (iter as AsyncIterable<{ id: string }[]>)[Symbol.asyncIterator]();
9696

@@ -104,7 +104,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
104104
// iterator yields again with the new row included.
105105
const inserted = await rpc(async (api) => {
106106
const user = await api.currentUser();
107-
return (await user.insertDraftOrder(api.db)).id;
107+
return (await user.insertDraftOrder(api.conn)).id;
108108
});
109109

110110
const second = await it.next();
@@ -120,7 +120,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
120120
const user = await api.currentUser();
121121
return user.orders()
122122
.select(({ orders }) => ({ id: orders.id, status: orders.status }))
123-
.live(api.db);
123+
.live(api.conn);
124124
});
125125
const it = (iter as AsyncIterable<{ id: string; status: string }[]>)[Symbol.asyncIterator]();
126126
const first = await it.next();
@@ -135,7 +135,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
135135
const user = await api.currentUser();
136136
return user.orders()
137137
.select(({ orders }) => ({ id: orders.id }))
138-
.live(api.db);
138+
.live(api.conn);
139139
});
140140
const it = (iter as AsyncIterable<{ id: string }[]>)[Symbol.asyncIterator]();
141141

@@ -169,7 +169,7 @@ describe("playground demo: cap-rooted API over exoeval RPC", () => {
169169
return u.orders()
170170
.select(({ orders }) => ({ id: orders.id }))
171171
.debug()
172-
.execute(api.db);
172+
.execute(api.conn);
173173
});
174174
expect(Array.isArray(result)).toBe(true);
175175
} finally {

site/src/demo/runtime.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { typegres } from "typegres";
66
import { runMigrations, runSeed } from "./seed";
77
import type { UserRoot } from "./server/api";
88

9-
export const db = await typegres<UserRoot>({ type: "pglite" });
9+
export const { db, conn } = await typegres<UserRoot>({ type: "pglite" });
1010

11-
await runMigrations(db);
12-
await runSeed(db);
11+
await runMigrations(conn);
12+
await runSeed(conn);
1313

1414
// `installLiveEvents` is a one-time DDL — production callers run it as
1515
// part of their migrations. The demo's storage doesn't survive page
1616
// reloads, so we run it on every boot. `startLive` then assumes the
1717
// events table exists and only spins up the polling bus.
18-
await db.installLiveEvents();
19-
await db.startLive();
18+
await conn.installLiveEvents();
19+
await conn.startLive();

0 commit comments

Comments
 (0)