Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,32 @@
import { BoundableStatement } from "./_internal/statement.mjs";
export default function cloudflareD1Connector(options) {
const getDB = () => {
// TODO: Remove legacy __cf_env__ support in next major version
const binding = globalThis.__env__?.[options.bindingName] || globalThis.__cf_env__?.[options.bindingName];
if (!binding) {
throw new Error(`[db0] [d1] binding \`${options.bindingName}\` not found`);
}
return binding;
};
return {
name: "cloudflare-d1",
dialect: "sqlite",
getInstance: () => getDB(),
exec: (sql) => getDB().exec(sql),
prepare: (sql) => new StatementWrapper(getDB().prepare(sql))
};
}
class StatementWrapper extends BoundableStatement {
async all(...params) {
const res = await this._statement.bind(...params).all();
return res.results;
}
async run(...params) {
const res = await this._statement.bind(...params).run();
return res;
}
async get(...params) {
const res = await this._statement.bind(...params).first();
return res;
}
}