because if D1 is efficient enough that table locking is not much of an issue, i guess ill go with a
because if D1 is efficient enough that table locking is not much of an issue, i guess ill go with a monolitic DB design and lots of workers
-- Create a table. And an external content fts5 table to index it.
CREATE TABLE tbl(a INTEGER PRIMARY KEY, b, c);
CREATE VIRTUAL TABLE fts_idx USING fts5(b, c, content='tbl', content_rowid='a');
-- Triggers to keep the FTS index up to date.
CREATE TRIGGER tbl_ai AFTER INSERT ON tbl BEGIN
INSERT INTO fts_idx(rowid, b, c) VALUES (new.a, new.b, new.c);
END;
CREATE TRIGGER tbl_ad AFTER DELETE ON tbl BEGIN
INSERT INTO fts_idx(fts_idx, rowid, b, c) VALUES('delete', old.a, old.b, old.c);
END;
CREATE TRIGGER tbl_au AFTER UPDATE ON tbl BEGIN
INSERT INTO fts_idx(fts_idx, rowid, b, c) VALUES('delete', old.a, old.b, old.c);
INSERT INTO fts_idx(rowid, b, c) VALUES (new.a, new.b, new.c);
END;
"@cloudflare/workers-types": "^4.20230710.1"first return Record<string, T> but not T? 4.20230518.0:DROP TABLE IF EXISTS [table001] statement, and wrangler returns an error no such table: main.[table001]?
main.table_name. Just table_name.
DROP TABLE IF EXISTS runs fine in DBeaver, but not wrangler@3.20
wrangler d1 execute report this.
--command='PRAGMA table_list'wrangler d1 execute <db> --command='PRAGMA table_list' --local--local is local. If you don't pass --local, and run wrangler d1 execute [...] execute DB_NAME --file=export.sql to import your old database.
-- Create a table. And an external content fts5 table to index it.
CREATE TABLE tbl(a INTEGER PRIMARY KEY, b, c);
CREATE VIRTUAL TABLE fts_idx USING fts5(b, c, content='tbl', content_rowid='a');
-- Triggers to keep the FTS index up to date.
CREATE TRIGGER tbl_ai AFTER INSERT ON tbl BEGIN
INSERT INTO fts_idx(rowid, b, c) VALUES (new.a, new.b, new.c);
END;
CREATE TRIGGER tbl_ad AFTER DELETE ON tbl BEGIN
INSERT INTO fts_idx(fts_idx, rowid, b, c) VALUES('delete', old.a, old.b, old.c);
END;
CREATE TRIGGER tbl_au AFTER UPDATE ON tbl BEGIN
INSERT INTO fts_idx(fts_idx, rowid, b, c) VALUES('delete', old.a, old.b, old.c);
INSERT INTO fts_idx(rowid, b, c) VALUES (new.a, new.b, new.c);
END;
declare abstract class D1PreparedStatement {
bind(...values: any[]): D1PreparedStatement;
first<T = unknown>(colName: string): Promise<T | null>;
first<T = unknown>(): Promise<Record<string, T> | null>;
run<T = unknown>(): Promise<D1Result<T>>;
all<T = unknown>(): Promise<D1Result<T[]>>;
raw<T = unknown>(): Promise<T[]>;
}declare abstract class D1PreparedStatement {
bind(...values: any[]): D1PreparedStatement;
first<T = unknown>(colName?: string): Promise<T>;
run<T = unknown>(): Promise<D1Result<T>>;
all<T = unknown>(): Promise<D1Result<T>>;
raw<T = unknown>(): Promise<T[]>;
}