Skip to content

Commit 31d4796

Browse files
authored
feat: Experimental support for Node.js and better-sqlite3 (#11)
1 parent daaf539 commit 31d4796

File tree

11 files changed

+1232
-1
lines changed

11 files changed

+1232
-1
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,24 @@ sql:
311311
runtime: node
312312
driver: mysql2 # npm package name
313313
```
314+
315+
### SQLite and better-sqlite3 (Beta)
316+
317+
```yaml
318+
version: '2'
319+
plugins:
320+
- name: ts
321+
wasm:
322+
url: https://downloads.sqlc.dev/plugin/sqlc-gen-typescript_0.1.3.wasm
323+
sha256: 287df8f6cc06377d67ad5ba02c9e0f00c585509881434d15ea8bd9fc751a9368
324+
sql:
325+
- schema: "schema.sql"
326+
queries: "query.sql"
327+
engine: sqlite
328+
codegen:
329+
- out: db
330+
plugin: ts
331+
options:
332+
runtime: node
333+
driver: better-sqlite3 # npm package name
334+
```

examples/authors/sqlite/query.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- name: GetAuthor :one
2+
SELECT * FROM authors
3+
WHERE id = ? LIMIT 1;
4+
5+
-- name: ListAuthors :many
6+
SELECT * FROM authors
7+
ORDER BY name;
8+
9+
-- name: CreateAuthor :exec
10+
INSERT INTO authors (
11+
name, bio
12+
) VALUES (
13+
?, ?
14+
);
15+
16+
-- name: DeleteAuthor :exec
17+
DELETE FROM authors
18+
WHERE id = ?;

examples/authors/sqlite/schema.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE TABLE authors (
2+
id INTEGER PRIMARY KEY AUTOINCREMENT,
3+
name text NOT NULL,
4+
bio text
5+
);

0 commit comments

Comments
 (0)