Skip to content
Open
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
2 changes: 1 addition & 1 deletion docs/bundler/fullstack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ import dashboard from "./public/dashboard.html";

// Initialize database
const db = new Database("app.db");
db.exec(`
db.run(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion docs/runtime/http/server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ import type { Post } from "./types.ts";
import { Database } from "bun:sqlite";

const db = new Database("posts.db");
db.exec(`
db.run(`
CREATE TABLE IF NOT EXISTS posts (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion docs/runtime/sqlite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ SQLite supports [write-ahead log mode](https://www.sqlite.org/wal.html) (WAL) wh
To enable WAL mode, run this pragma query at the beginning of your application:

```ts db.ts icon="/icons/typescript.svg"
db.exec("PRAGMA journal_mode = WAL;");
db.run("PRAGMA journal_mode = WAL;");
```

<Accordion title="What is WAL mode?">
Expand Down
26 changes: 13 additions & 13 deletions packages/bun-types/sqlite.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ declare module "bun:sqlite" {
* // setup
* import { Database } from "bun:sqlite";
* const db = Database.open(":memory:");
* db.exec(
* db.run(
* "CREATE TABLE cats (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE, age INTEGER)"
* );
*
Expand Down Expand Up @@ -423,9 +423,9 @@ declare module "bun:sqlite" {
* ```ts
* test("supports serialize/deserialize", () => {
* const db = Database.open(":memory:");
* db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)");
* db.exec('INSERT INTO test (name) VALUES ("Hello")');
* db.exec('INSERT INTO test (name) VALUES ("World")');
* db.run("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)");
* db.run('INSERT INTO test (name) VALUES ("Hello")');
* db.run('INSERT INTO test (name) VALUES ("World")');
*
* const input = db.serialize();
* const db2 = new Database(input);
Expand All @@ -450,7 +450,7 @@ declare module "bun:sqlite" {
* },
* ]),
* );
* db2.exec("insert into test (name) values ('foo')");
* db2.run("insert into test (name) values ('foo')");
* expect(JSON.stringify(stmt.all())).toBe(
* JSON.stringify([
* {
Expand All @@ -470,7 +470,7 @@ declare module "bun:sqlite" {
*
* const db3 = Database.deserialize(input, true);
* try {
* db3.exec("insert into test (name) values ('foo')");
* db3.run("insert into test (name) values ('foo')");
* throw new Error("Expected error");
* } catch (e) {
* expect(e.message).toBe("attempt to write a readonly database");
Expand All @@ -493,9 +493,9 @@ declare module "bun:sqlite" {
* ```ts
* test("supports serialize/deserialize", () => {
* const db = Database.open(":memory:");
* db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)");
* db.exec('INSERT INTO test (name) VALUES ("Hello")');
* db.exec('INSERT INTO test (name) VALUES ("World")');
* db.run("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)");
* db.run('INSERT INTO test (name) VALUES ("Hello")');
* db.run('INSERT INTO test (name) VALUES ("World")');
*
* const input = db.serialize();
* const db2 = Database.deserialize(input, { strict: true });
Expand All @@ -520,7 +520,7 @@ declare module "bun:sqlite" {
* },
* ]),
* );
* db2.exec("insert into test (name) values ($foo)", { foo: "baz" });
* db2.run("insert into test (name) values ($foo)", { foo: "baz" });
* expect(JSON.stringify(stmt.all())).toBe(
* JSON.stringify([
* {
Expand All @@ -540,7 +540,7 @@ declare module "bun:sqlite" {
*
* const db3 = Database.deserialize(input, { readonly: true, strict: true });
* try {
* db3.exec("insert into test (name) values ($foo)", { foo: "baz" });
* db3.run("insert into test (name) values ($foo)", { foo: "baz" });
* throw new Error("Expected error");
* } catch (e) {
* expect(e.message).toBe("attempt to write a readonly database");
Expand Down Expand Up @@ -925,7 +925,7 @@ declare module "bun:sqlite" {
* }
*
* const db = new Database(":memory:");
* db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, rawBirthdate TEXT)");
* db.run("CREATE TABLE users (id INTEGER PRIMARY KEY, rawBirthdate TEXT)");
* db.run("INSERT INTO users (rawBirthdate) VALUES ('1995-12-19')");
* const query = db.query("SELECT * FROM users");
* query.as(User);
Expand Down Expand Up @@ -1108,7 +1108,7 @@ declare module "bun:sqlite" {
* const db = Database.open("mydb.sqlite");
* db.fileControl(constants.SQLITE_FCNTL_PERSIST_WAL, 0);
* // enable WAL
* db.exec("PRAGMA journal_mode = WAL");
* db.run("PRAGMA journal_mode = WAL");
* // .. do some work
* db.close();
* ```
Expand Down