Skip to content

Commit c897405

Browse files
committed
docs: initialize new docs
1 parent f85fa93 commit c897405

33 files changed

+259
-6972
lines changed

docs/.config/docs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# yaml-language-server: $schema=https://unpkg.com/undocs/schema/config.json
2+
3+
name: "db0"
4+
shortDescription: "elegant Database API"
5+
description: ""
6+
github: "unjs/db0"
7+
url: "https://db0.unjs.io"
8+
automd: true
9+
themeColor: "orange"
10+
# landing:
11+
# contributors: true
12+
# heroLinks:
13+
# stackblitz:
14+
# icon: "i-heroicons-play"
15+
# to: "https://stackblitz.com/github/unjs/packageName/tree/main/playground"
16+
# features:
17+
# - title:
18+
# description:

docs/.docs/public/icon.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/.gitignore

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
node_modules
2-
*.iml
3-
.idea
4-
*.log*
52
.nuxt
6-
.vscode
7-
.DS_Store
8-
coverage
9-
dist
10-
sw.*
11-
.env
123
.output
4+
dist

docs/.npmrc

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
# Usage
1+
---
2+
icon: ph:book-open-duotone
3+
---
24

3-
Discover how to use `db0` in your project.
5+
# Getting Started
46

5-
## Installation
7+
> db0 provides an easy way to connect and query sql databases providers.
68
7-
Install [`db0`](https://npmjs.com/package/db0) npm package:
8-
9-
::code-group
9+
DB0 provides Elegant API to query your databases. It is designed to work in all JavaScript runtimes and with different Database types using [connectors](/connectors).
1010

11-
```sh [npm]
12-
npm install db0
13-
```
14-
15-
```sh [Yarn]
16-
yarn add db0
17-
```
11+
> [!IMPORTANT]
12+
> DB0 is under development and API might change.
1813
19-
```sh [pnpm]
20-
pnpm add db0
21-
```
14+
## Quick start
2215

23-
::
16+
Install [`db0`](https://npmjs.com/package/db0) npm package:
2417

25-
## Usage
18+
:pm-install{name="db0"}
2619

2720
```ts
2821
import { createDatabase, sql } from "db0";
@@ -42,3 +35,9 @@ await db.sql`INSERT INTO users VALUES (${userId}, 'John', 'Doe', '')`;
4235
const { rows } = await db.sql`SELECT * FROM users WHERE id = ${userId}`;
4336
console.log(rows);
4437
```
38+
39+
## Next steps
40+
41+
:read-more{to="/connectors"}
42+
43+
:read-more{to="/integrations"}

docs/1.guide/3.http-server.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
icon: material-symbols:http
3+
---
4+
5+
# HTTP Server
6+
7+
> Expose SQL databases over (secure) HTTP as a restfu API for edge runtimes!
8+
9+
> [!NOTE]
10+
> 🚀 This feature is planned! Follow up [unjs/db0#6](https://github.com/unjs/db0/issues/6)

docs/1.guide/4.custom-connector.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
icon: material-symbols-light:dashboard-customize
3+
---
4+
5+
# Custom Connectors
6+
7+
If there is no built-in connector yet for a SQL database integration, you can create a custom one by yourself.
8+
9+
::read-more{to="https://github.com/unjs/db0/tree/main/src/connectors"}
10+
Explore [built-in connectors](https://github.com/unjs/db0/tree/main/src/connectors) to learn how to implement a custom connector.
11+
::
12+
13+
> [!NOTE]
14+
> Feel free to [request new a new connector](https://github.com/unjs/db0/issues/new?assignees=&labels=connector&projects=&template=feature-request.yml).

docs/2.connectors/1.index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
icon: gravity-ui:plug-connection
3+
---
4+
5+
# Connectors
6+
7+
> You can use DB0 api with the connector of your own choice.
8+
9+
See left sections for each connector instructions.

docs/content/100.connectors/cloudflare-d1.md renamed to docs/2.connectors/cloudflare.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
---
2-
navigation.title: Cloudflare D1
2+
icon: devicon-plain:cloudflareworkers
33
---
44

5-
# Cloudflare D1 Connector
5+
# Cloudflare D1
6+
7+
> Connect DB0 to Cloudflare D1 database
8+
9+
:read-more{to="https://developers.cloudflare.com/d1"}
10+
11+
> [!NOTE]
12+
> This connector works within cloudflare workers with D1 enabled.
613
714
## Usage
815

9-
This connector works within cloudflare workers with D1 enabled. [Read More](https://developers.cloudflare.com/d1/)
16+
Use `cloudflare-d1` connector:
1017

1118
```js
1219
import { createDatabase, sql } from "db0";

docs/content/100.connectors/libsql.md renamed to docs/2.connectors/libsql.md

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,38 @@
11
---
2-
navigation.title: LibSQL
2+
icon: clarity:node-line
33
---
44

5-
# LibSQL Connector
5+
# LibSQL
66

7-
Connect to a [LibSQL](https://libsql.org/) database.
7+
> Connect DB0 to LibSQL database
8+
9+
:read-more{to="https://libsql.org"}
810

911
## Usage
1012

1113
For this connector, you need to install [`@libsql/client`](https://www.npmjs.com/package/@libsql/client) dependency:
1214

13-
::code-group
14-
15-
```sh [npm]
16-
npm install @libsql/client
17-
```
18-
19-
```sh [Yarn]
20-
yarn add @libsql/client
21-
```
22-
23-
```sh [pnpm]
24-
pnpm add @libsql/client
25-
```
26-
27-
::
15+
:pm-install{name="@libsql/client"}
2816

29-
<br>
17+
Choose on of the `libsql`, `libsql/http` or `libsql/web` connectors depending on your usage requirements:
3018

3119
::code-group
3220

33-
```ts [Node.js]
21+
```ts [libsql.node.js]
3422
import { createDatabase, sql } from "db0";
3523
import libSql from "db0/connectors/libsql";
3624

3725
const db = createDatabase(libSql({ url: `file:local.db` }));
3826
```
3927

40-
```ts [Http]
28+
```ts [libsql.http.js]
4129
import { createDatabase, sql } from "db0";
4230
import libSql from "db0/connectors/libsql/http";
4331

4432
const db = createDatabase(libSql({}));
4533
```
4634

47-
```ts [Web]
35+
```ts [libsql.web.js]
4836
import { createDatabase, sql } from "db0";
4937
import libSql from "db0/connectors/libsql/web";
5038

docs/2.connectors/planetscale.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
icon: simple-icons:planetscale
3+
---
4+
5+
# PlanetScale
6+
7+
> Connect DB0 to Planetscale
8+
9+
:read-more{to="https://planetscale.com"}
10+
11+
> [!WARNING]
12+
> 🚀 This connector will be supported soon! Follow up via [unjs/db0#4](https://github.com/unjs/db0/issues/4).
13+
14+
## Usage
15+
16+
Use `planetscale` connector:
17+
18+
```js
19+
import { createDatabase, sql } from "db0";
20+
import planetscale from "db0/connectors/planetscale";
21+
22+
const db = createDatabase(
23+
planetscale({
24+
/* options */
25+
}),
26+
);
27+
```

docs/2.connectors/postgresql.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
icon: simple-icons:postgresql
3+
---
4+
5+
# PostgreSQL
6+
7+
> Connect DB0 to PostgreSQL
8+
9+
:read-more{to="https://www.postgresql.org"}
10+
11+
## Usage
12+
13+
For this connector, you need to install [`pg`](https://www.npmjs.com/package/pg) dependency:
14+
15+
:pm-install{name="pg@8 @types/pg@8"}
16+
17+
Use `postgresql` connector:
18+
19+
```js
20+
import { createDatabase, sql } from "db0";
21+
import postgresql from "db0/connectors/postgresql";
22+
23+
const db = createDatabase(
24+
postgresql({
25+
bindingName: "DB",
26+
}),
27+
);
28+
```
29+
30+
## Options
31+
32+
### `url`
33+
34+
Connection URL string.
35+
36+
Alternatively, you can add connection configuration.
37+
38+
:read-more{title="node-postgres client options" to="https://node-postgres.com/apis/client#new-client"}

docs/content/100.connectors/sqlite.md renamed to docs/2.connectors/sqlite.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
---
2-
navigation.title: SQLite
2+
icon: simple-icons:sqlite
33
---
44

5-
# SQLite Connector
5+
# SQLite
66

7-
## Usage
8-
9-
For this connector, you need to install [`better-sqlite3`](https://www.npmjs.com/package/better-sqlite3) dependency:
7+
> Connect DB0 to SQLite using better-sqlite3
108
11-
::code-group
9+
<!-- :read-more{to=""} -->
1210

13-
```sh [npm]
14-
npm install better-sqlite3@8
15-
```
11+
## Usage
1612

17-
```sh [Yarn]
18-
yarn add better-sqlite3@8
19-
```
13+
For this connector, you need to install [`better-sqlite3`](https://www.npmjs.com/package/better-sqlite3) dependency:
2014

21-
```sh [pnpm]
22-
pnpm add better-sqlite3@8
23-
```
15+
:pm-i{name="better-sqlite3@8"}
2416

25-
::
17+
Use `better-sqlite3` connector:
2618

2719
```js
2820
import { createDatabase, sql } from "db0";

docs/2.connectors/turso.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
icon: simple-icons:turso
3+
---
4+
5+
# Turso
6+
7+
> Connect DB0 to Turso database
8+
9+
:read-more{to="https://turso.tech"}
10+
11+
> [!WARNING]
12+
> 🚀 This connector will be supported soon! Follow up via [unjs/db0#11](https://github.com/unjs/db0/issues/11).
13+
14+
Use ~~`turso`~~ connector:
15+
16+
```js
17+
import { createDatabase, sql } from "db0";
18+
import vercelPostgres from "db0/connectors/turso";
19+
20+
const db = createDatabase(
21+
turso({
22+
/* options */
23+
}),
24+
);
25+
```

docs/2.connectors/vercel.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
icon: radix-icons:vercel-logo
3+
---
4+
5+
# Vercel
6+
7+
Connect to [Vercel Postgres](https://vercel.com/docs/storage/vercel-postgres) database.
8+
9+
:read-more{to="https://vercel.com/docs/storage/vercel-postgres"}
10+
11+
> [!WARNING]
12+
> 🚀 This connector will be supported soon! Follow up via [unjs/db0#3](https://github.com/unjs/db0/issues/3). In the meantime you can directly use [PostgreSQL connector](/connectors/postgresql).
13+
14+
## Usage
15+
16+
Use [`postgress`](/connectors/postgresql) connector.
17+
18+
```js
19+
import { createDatabase, sql } from "db0";
20+
import postgres from "db0/connectors/postgres";
21+
22+
const db = createDatabase(
23+
postgres({
24+
/* options */
25+
}),
26+
);
27+
```

docs/3.integrations/1.index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
icon: carbon:property-relationship
3+
---
4+
5+
# Integrations
6+
7+
> You can integrate DB0 instance to ORM or framework of your choice.
8+
9+
See left sections for each integration instructions.

0 commit comments

Comments
 (0)