Skip to content

Commit

Permalink
refactor: use createDatabase
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 21, 2023
1 parent 59df1d2 commit 84c52d8
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`;
Expand Down
6 changes: 3 additions & 3 deletions docs/content/100.connectors/cloudflare-d1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
}),
);
```

Expand Down
12 changes: 6 additions & 6 deletions docs/content/100.connectors/libsql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({}));
```

::
Expand Down
6 changes: 3 additions & 3 deletions docs/content/100.connectors/planetscale.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
})
}),
);
```
6 changes: 3 additions & 3 deletions docs/content/100.connectors/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
}),
);
```

Expand Down
6 changes: 3 additions & 3 deletions docs/content/100.connectors/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
})
}),
);
```

Expand Down
6 changes: 3 additions & 3 deletions docs/content/100.connectors/turso.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
})
}),
);
```
6 changes: 3 additions & 3 deletions docs/content/100.connectors/vercel-postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
})
}),
);
```
4 changes: 2 additions & 2 deletions docs/content/2.usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./db";
export * from "./database";
export * from "./types";

export const connectors = {
Expand Down

0 comments on commit 84c52d8

Please sign in to comment.