Skip to content

Commit

Permalink
docs: initialize new docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 26, 2024
1 parent f85fa93 commit c897405
Show file tree
Hide file tree
Showing 33 changed files with 259 additions and 6,972 deletions.
18 changes: 18 additions & 0 deletions docs/.config/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# yaml-language-server: $schema=https://unpkg.com/undocs/schema/config.json

name: "db0"
shortDescription: "elegant Database API"
description: ""
github: "unjs/db0"
url: "https://db0.unjs.io"
automd: true
themeColor: "orange"
# landing:
# contributors: true
# heroLinks:
# stackblitz:
# icon: "i-heroicons-play"
# to: "https://stackblitz.com/github/unjs/packageName/tree/main/playground"
# features:
# - title:
# description:
1 change: 1 addition & 0 deletions docs/.docs/public/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 1 addition & 9 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
node_modules
*.iml
.idea
*.log*
.nuxt
.vscode
.DS_Store
coverage
dist
sw.*
.env
.output
dist
2 changes: 0 additions & 2 deletions docs/.npmrc

This file was deleted.

35 changes: 17 additions & 18 deletions docs/content/2.usage.md → docs/1.guide/1.index.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
# Usage
---
icon: ph:book-open-duotone
---

Discover how to use `db0` in your project.
# Getting Started

## Installation
> db0 provides an easy way to connect and query sql databases providers.
Install [`db0`](https://npmjs.com/package/db0) npm package:

::code-group
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).

```sh [npm]
npm install db0
```

```sh [Yarn]
yarn add db0
```
> [!IMPORTANT]
> DB0 is under development and API might change.
```sh [pnpm]
pnpm add db0
```
## Quick start

::
Install [`db0`](https://npmjs.com/package/db0) npm package:

## Usage
:pm-install{name="db0"}

```ts
import { createDatabase, sql } from "db0";
Expand All @@ -42,3 +35,9 @@ await db.sql`INSERT INTO users VALUES (${userId}, 'John', 'Doe', '')`;
const { rows } = await db.sql`SELECT * FROM users WHERE id = ${userId}`;
console.log(rows);
```

## Next steps

:read-more{to="/connectors"}

:read-more{to="/integrations"}
10 changes: 10 additions & 0 deletions docs/1.guide/3.http-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
icon: material-symbols:http
---

# HTTP Server

> Expose SQL databases over (secure) HTTP as a restfu API for edge runtimes!
> [!NOTE]
> 🚀 This feature is planned! Follow up [unjs/db0#6](https://github.com/unjs/db0/issues/6)
14 changes: 14 additions & 0 deletions docs/1.guide/4.custom-connector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
icon: material-symbols-light:dashboard-customize
---

# Custom Connectors

If there is no built-in connector yet for a SQL database integration, you can create a custom one by yourself.

::read-more{to="https://github.com/unjs/db0/tree/main/src/connectors"}
Explore [built-in connectors](https://github.com/unjs/db0/tree/main/src/connectors) to learn how to implement a custom connector.
::

> [!NOTE]
> Feel free to [request new a new connector](https://github.com/unjs/db0/issues/new?assignees=&labels=connector&projects=&template=feature-request.yml).
9 changes: 9 additions & 0 deletions docs/2.connectors/1.index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
icon: gravity-ui:plug-connection
---

# Connectors

> You can use DB0 api with the connector of your own choice.
See left sections for each connector instructions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
---
navigation.title: Cloudflare D1
icon: devicon-plain:cloudflareworkers
---

# Cloudflare D1 Connector
# Cloudflare D1

> Connect DB0 to Cloudflare D1 database
:read-more{to="https://developers.cloudflare.com/d1"}

> [!NOTE]
> This connector works within cloudflare workers with D1 enabled.
## Usage

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

```js
import { createDatabase, sql } from "db0";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,38 @@
---
navigation.title: LibSQL
icon: clarity:node-line
---

# LibSQL Connector
# LibSQL

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

## Usage

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

::code-group

```sh [npm]
npm install @libsql/client
```

```sh [Yarn]
yarn add @libsql/client
```

```sh [pnpm]
pnpm add @libsql/client
```

::
:pm-install{name="@libsql/client"}

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

::code-group

```ts [Node.js]
```ts [libsql.node.js]
import { createDatabase, sql } from "db0";
import libSql from "db0/connectors/libsql";

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

```ts [Http]
```ts [libsql.http.js]
import { createDatabase, sql } from "db0";
import libSql from "db0/connectors/libsql/http";

const db = createDatabase(libSql({}));
```

```ts [Web]
```ts [libsql.web.js]
import { createDatabase, sql } from "db0";
import libSql from "db0/connectors/libsql/web";

Expand Down
27 changes: 27 additions & 0 deletions docs/2.connectors/planetscale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
icon: simple-icons:planetscale
---

# PlanetScale

> Connect DB0 to Planetscale
:read-more{to="https://planetscale.com"}

> [!WARNING]
> 🚀 This connector will be supported soon! Follow up via [unjs/db0#4](https://github.com/unjs/db0/issues/4).
## Usage

Use `planetscale` connector:

```js
import { createDatabase, sql } from "db0";
import planetscale from "db0/connectors/planetscale";

const db = createDatabase(
planetscale({
/* options */
}),
);
```
38 changes: 38 additions & 0 deletions docs/2.connectors/postgresql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
icon: simple-icons:postgresql
---

# PostgreSQL

> Connect DB0 to PostgreSQL
:read-more{to="https://www.postgresql.org"}

## Usage

For this connector, you need to install [`pg`](https://www.npmjs.com/package/pg) dependency:

:pm-install{name="pg@8 @types/pg@8"}

Use `postgresql` connector:

```js
import { createDatabase, sql } from "db0";
import postgresql from "db0/connectors/postgresql";

const db = createDatabase(
postgresql({
bindingName: "DB",
}),
);
```

## Options

### `url`

Connection URL string.

Alternatively, you can add connection configuration.

:read-more{title="node-postgres client options" to="https://node-postgres.com/apis/client#new-client"}
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
---
navigation.title: SQLite
icon: simple-icons:sqlite
---

# SQLite Connector
# SQLite

## Usage

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

```sh [npm]
npm install better-sqlite3@8
```
## Usage

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

```sh [pnpm]
pnpm add better-sqlite3@8
```
:pm-i{name="better-sqlite3@8"}

::
Use `better-sqlite3` connector:

```js
import { createDatabase, sql } from "db0";
Expand Down
25 changes: 25 additions & 0 deletions docs/2.connectors/turso.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
icon: simple-icons:turso
---

# Turso

> Connect DB0 to Turso database
:read-more{to="https://turso.tech"}

> [!WARNING]
> 🚀 This connector will be supported soon! Follow up via [unjs/db0#11](https://github.com/unjs/db0/issues/11).
Use ~~`turso`~~ connector:

```js
import { createDatabase, sql } from "db0";
import vercelPostgres from "db0/connectors/turso";

const db = createDatabase(
turso({
/* options */
}),
);
```
27 changes: 27 additions & 0 deletions docs/2.connectors/vercel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
icon: radix-icons:vercel-logo
---

# Vercel

Connect to [Vercel Postgres](https://vercel.com/docs/storage/vercel-postgres) database.

:read-more{to="https://vercel.com/docs/storage/vercel-postgres"}

> [!WARNING]
> 🚀 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).
## Usage

Use [`postgress`](/connectors/postgresql) connector.

```js
import { createDatabase, sql } from "db0";
import postgres from "db0/connectors/postgres";

const db = createDatabase(
postgres({
/* options */
}),
);
```
9 changes: 9 additions & 0 deletions docs/3.integrations/1.index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
icon: carbon:property-relationship
---

# Integrations

> You can integrate DB0 instance to ORM or framework of your choice.
See left sections for each integration instructions.
Loading

0 comments on commit c897405

Please sign in to comment.