Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 93cbe93

Browse files
committed
feat: sqlite v2
1 parent ea57692 commit 93cbe93

37 files changed

+482
-261
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,5 @@ Cargo.lock
184184
**/.wrangler
185185
**/.DS_Store
186186
.aider*
187+
188+
packages/**/tsup.config.bundled_*.mjs

examples/drizzle/drizzle/meta/0000_snapshot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": "6",
33
"dialect": "sqlite",
4-
"id": "22f3d49c-97d5-46ca-b0f1-99950c3efec7",
4+
"id": "5175c351-75eb-4f1d-9211-7ee520f0b9c2",
55
"prevId": "00000000-0000-0000-0000-000000000000",
66
"tables": {
77
"users_table": {

examples/drizzle/drizzle/meta/_journal.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@
55
{
66
"idx": 0,
77
"version": "6",
8-
"when": 1750711614205,
9-
"tag": "0000_wonderful_iron_patriot",
10-
"breakpoints": true
11-
},
12-
{
13-
"idx": 1,
14-
"version": "6",
15-
"when": 1750716663518,
16-
"tag": "0001_rich_susan_delgado",
8+
"when": 1750976447195,
9+
"tag": "0000_moaning_tomorrow_man",
1710
"breakpoints": true
1811
}
1912
]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import journal from './meta/_journal.json';
2-
import m0000 from './0000_wonderful_iron_patriot.sql';
2+
import m0000 from './0000_moaning_tomorrow_man.sql';
33

44
export default {
55
journal,
66
migrations: {
7-
m0000,
7+
m0000
88
}
99
}
1010

examples/drizzle/hooks.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/drizzle/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"dev": "tsx --watch src/server.ts",
7+
"dev": "tsx --loader @rivetkit/sql-loader --watch src/server.ts",
88
"check-types": "tsc --noEmit"
99
},
1010
"devDependencies": {
11+
"@rivetkit/actor": "workspace:*",
12+
"@rivetkit/sql-loader": "workspace:*",
1113
"@types/node": "^22.13.9",
12-
"rivetkit": "workspace:*",
1314
"tsx": "^3.12.7",
1415
"typescript": "^5.5.2"
1516
},
1617
"dependencies": {
1718
"@rivetkit/db": "workspace:0.9.0-rc.1",
19+
"better-sqlite3": "^12.1.1",
1820
"drizzle-kit": "^0.31.2",
1921
"drizzle-orm": "^0.44.2"
2022
},

examples/drizzle/register.js

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/// <reference types="node" />
2+
import { createClient } from "@rivetkit/actor/client";
3+
import type { Registry } from "../src/registry";
4+
5+
async function main() {
6+
const client = createClient<Registry>(
7+
process.env.ENDPOINT ?? "http://127.0.0.1:8080",
8+
);
9+
10+
const contacts = client.contacts.getOrCreate();
11+
12+
// counter.on("newCount", (count: number) => console.log("Event:", count));
13+
14+
for (let i = 0; i < 5; i++) {
15+
const out = await contacts.insert({
16+
name: `User ${i}`,
17+
age: 20 + i,
18+
email: `example+${i}@example.com`,
19+
});
20+
console.log("Inserted:", out);
21+
}
22+
23+
console.log("Reading all users:");
24+
const users = await contacts.read();
25+
console.log(users);
26+
27+
// await counter.dispose();
28+
}
29+
30+
main();

examples/drizzle/src/db/schema.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// import { int, sqliteTable, text } from "@rivetkit/db/drizzle";
1+
import { int, sqliteTable, text } from "@rivetkit/db/drizzle";
22

3-
// export const usersTable = sqliteTable("users_table", {
4-
// id: int().primaryKey({ autoIncrement: true }),
5-
// name: text().notNull(),
6-
// age: int().notNull(),
7-
// email: text().notNull().unique(),
8-
// email2: text().notNull().unique(),
9-
// });
3+
export const usersTable = sqliteTable("users_table", {
4+
id: int().primaryKey({ autoIncrement: true }),
5+
name: text().notNull(),
6+
age: int().notNull(),
7+
email: text().notNull().unique(),
8+
});

0 commit comments

Comments
 (0)