Skip to content

feat: Experimental support for Node.js and better-sqlite3 #11

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

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,24 @@ sql:
runtime: node
driver: mysql2 # npm package name
```

### SQLite and better-sqlite3 (Beta)

```yaml
version: '2'
plugins:
- name: ts
wasm:
url: https://downloads.sqlc.dev/plugin/sqlc-gen-typescript_0.1.3.wasm
sha256: 287df8f6cc06377d67ad5ba02c9e0f00c585509881434d15ea8bd9fc751a9368
sql:
- schema: "schema.sql"
queries: "query.sql"
engine: sqlite
codegen:
- out: db
plugin: ts
options:
runtime: node
driver: better-sqlite3 # npm package name
```
18 changes: 18 additions & 0 deletions examples/authors/sqlite/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = ? LIMIT 1;

-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name;

-- name: CreateAuthor :exec
INSERT INTO authors (
name, bio
) VALUES (
?, ?
);

-- name: DeleteAuthor :exec
DELETE FROM authors
WHERE id = ?;
5 changes: 5 additions & 0 deletions examples/authors/sqlite/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE authors (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name text NOT NULL,
bio text
);
Loading