From 84c52d83dd3568b0393cc913c0685b0261c13ab4 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 21 Jul 2023 18:35:23 +0200 Subject: [PATCH] refactor: use `createDatabase` --- README.md | 4 ++-- docs/content/100.connectors/cloudflare-d1.md | 6 +++--- docs/content/100.connectors/libsql.md | 12 ++++++------ docs/content/100.connectors/planetscale.md | 6 +++--- docs/content/100.connectors/postgresql.md | 6 +++--- docs/content/100.connectors/sqlite.md | 6 +++--- docs/content/100.connectors/turso.md | 6 +++--- docs/content/100.connectors/vercel-postgresql.md | 6 +++--- docs/content/2.usage.md | 4 ++-- src/{db.ts => database.ts} | 0 src/index.ts | 2 +- 11 files changed, 29 insertions(+), 29 deletions(-) rename src/{db.ts => database.ts} (100%) diff --git a/README.md b/README.md index f68e813..eb92137 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,11 @@ pnpm add db0 ``` ```js -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import sqlite from "db0/connectors/better-sqlite3"; // Initiate database with SQLite connector -const db = createDB(sqlite({})); +const db = createDatabase(sqlite({})); // Create users table await db.sql`CREATE TABLE IF NOT EXISTS users ("id" TEXT PRIMARY KEY, "firstName" TEXT, "lastName" TEXT, "email" TEXT)`; diff --git a/docs/content/100.connectors/cloudflare-d1.md b/docs/content/100.connectors/cloudflare-d1.md index cc299e2..8590ba3 100644 --- a/docs/content/100.connectors/cloudflare-d1.md +++ b/docs/content/100.connectors/cloudflare-d1.md @@ -9,13 +9,13 @@ navigation.title: Cloudflare D1 This connector works within cloudflare workers with D1 enabled. [Read More](https://developers.cloudflare.com/d1/) ```js -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import cloudflareD1 from "db0/connectors/cloudflare-d1"; -const db = createDB( +const db = createDatabase( cloudflareD1({ bindingName: "DB", - }) + }), ); ``` diff --git a/docs/content/100.connectors/libsql.md b/docs/content/100.connectors/libsql.md index bcb4a91..9a12fc5 100644 --- a/docs/content/100.connectors/libsql.md +++ b/docs/content/100.connectors/libsql.md @@ -31,24 +31,24 @@ pnpm add @libsql/client ::code-group ```ts [Node.js] -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import libSql from "db0/connectors/libsql"; -const db = createDB(libSql({ url: `file:local.db` })); +const db = createDatabase(libSql({ url: `file:local.db` })); ``` ```ts [Http] -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import libSql from "db0/connectors/libsql/http"; -const db = createDB(libSql({})); +const db = createDatabase(libSql({})); ``` ```ts [Web] -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import libSql from "db0/connectors/libsql/web"; -const db = createDB(libSql({})); +const db = createDatabase(libSql({})); ``` :: diff --git a/docs/content/100.connectors/planetscale.md b/docs/content/100.connectors/planetscale.md index 3c34364..7a8c2df 100644 --- a/docs/content/100.connectors/planetscale.md +++ b/docs/content/100.connectors/planetscale.md @@ -11,12 +11,12 @@ Connect to [Planetscale](https://planetscale.com/) database. :: ```js -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import planetscale from "db0/connectors/planetscale"; -const db = createDB( +const db = createDatabase( planetscale({ /* options */ - }) + }), ); ``` diff --git a/docs/content/100.connectors/postgresql.md b/docs/content/100.connectors/postgresql.md index 8e6faf0..8203e3a 100644 --- a/docs/content/100.connectors/postgresql.md +++ b/docs/content/100.connectors/postgresql.md @@ -25,13 +25,13 @@ pnpm add pg@8 @types/pg@8 :: ```js -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import postgresql from "db0/connectors/postgresql"; -const db = createDB( +const db = createDatabase( postgresql({ bindingName: "DB", - }) + }), ); ``` diff --git a/docs/content/100.connectors/sqlite.md b/docs/content/100.connectors/sqlite.md index d51e081..1018b53 100644 --- a/docs/content/100.connectors/sqlite.md +++ b/docs/content/100.connectors/sqlite.md @@ -25,13 +25,13 @@ pnpm add better-sqlite3@8 :: ```js -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import sqlite from "db0/connectors/better-sqlite3"; -const db = createDB( +const db = createDatabase( sqlite({ /* options */ - }) + }), ); ``` diff --git a/docs/content/100.connectors/turso.md b/docs/content/100.connectors/turso.md index 11676cf..572457d 100644 --- a/docs/content/100.connectors/turso.md +++ b/docs/content/100.connectors/turso.md @@ -11,12 +11,12 @@ Connect to [Turso](https://turso.tech/) database. Follow up via [unjs/db0#11](ht :: ```js -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import vercelPostgres from "db0/connectors/turso"; -const db = createDB( +const db = createDatabase( turso({ /* options */ - }) + }), ); ``` diff --git a/docs/content/100.connectors/vercel-postgresql.md b/docs/content/100.connectors/vercel-postgresql.md index 058a97d..8d84dad 100644 --- a/docs/content/100.connectors/vercel-postgresql.md +++ b/docs/content/100.connectors/vercel-postgresql.md @@ -11,12 +11,12 @@ Connect to [Vercel Postgres](https://vercel.com/docs/storage/vercel-postgres) da :: ```js -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import vercelPostgres from "db0/connectors/vercel-postgres"; -const db = createDB( +const db = createDatabase( vercelPostgres({ /* options */ - }) + }), ); ``` diff --git a/docs/content/2.usage.md b/docs/content/2.usage.md index 8a8eab4..4530828 100644 --- a/docs/content/2.usage.md +++ b/docs/content/2.usage.md @@ -25,11 +25,11 @@ pnpm add db0 ## Usage ```ts -import { createDB, sql } from "db0"; +import { createDatabase, sql } from "db0"; import sqlite from "db0/connectors/better-sqlite3"; // Initiate database with SQLite connector -const db = createDB(sqlite({})); +const db = createDatabase(sqlite({})); // Create users table await db.sql`CREATE TABLE IF NOT EXISTS users ("id" TEXT PRIMARY KEY, "firstName" TEXT, "lastName" TEXT, "email" TEXT)`; diff --git a/src/db.ts b/src/database.ts similarity index 100% rename from src/db.ts rename to src/database.ts diff --git a/src/index.ts b/src/index.ts index 8c3f32b..c86fc97 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export * from "./db"; +export * from "./database"; export * from "./types"; export const connectors = {