Skip to content

Commit

Permalink
chore: initiate docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed May 19, 2023
1 parent 51823eb commit 16922ac
Show file tree
Hide file tree
Showing 22 changed files with 6,993 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sql0 provides an easy way to connect and query sql databases providers with a [t
## Features

- Designed for all environments: Browser, NodeJS, and Workers
- Lots of built-in connectors
- Well tested built-in connectors
- Asynchronous API

## Usage
Expand Down
12 changes: 12 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
*.iml
.idea
*.log*
.nuxt
.vscode
.DS_Store
coverage
dist
sw.*
.env
.output
2 changes: 2 additions & 0 deletions docs/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false
19 changes: 19 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Documentation

Docs are powered by [Docus](https://docus.dev).

## Local Development

Install dependencies:

```bash
pnpm install
```

Start development server with:

```bash
npm run dev
```

Start editing [conent](./content) directory!
26 changes: 26 additions & 0 deletions docs/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export default defineAppConfig({
docus: {
title: "SQL0",
description: "Universal Storage Layer.",
header: {
logo: false,
},
socials: {
twitter: "unjsio",
github: "unjs/sql0",
},
aside: {
level: 0,
exclude: [],
},
footer: {
iconLinks: [
{
href: "https://unjs.io",
icon: "vscode-icons:file-type-js-official",
label: "UnJS",
},
],
},
},
});
15 changes: 15 additions & 0 deletions docs/content/1.index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
navigation.title: Introduction
---

# Introduction

[unjs/sql0](https://github.com/unjs/sql0) provides an easy way to connect and query sql databases providers.

## Features

::list

- Designed for all environments: Browser, NodeJS, and Workers
- Well tested built-in connectors
- Asynchronous API
26 changes: 26 additions & 0 deletions docs/content/100.connectors/cloudflare-d1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
navigation.title: Cloudflare D1
---

# Cloudflare D1 Connector

## Usage

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

```js
import { createDB, sql } from "sql0";
import cloudflareD1 from "sql0/connectors/cloudflare-d1";

const db = createDB(
cloudflareD1({
bindingName: "DB",
})
);
```

## Options

### `bindingName`

Assigned binding name.
22 changes: 22 additions & 0 deletions docs/content/100.connectors/libsql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
navigation.title: LibSQL
---

# LibSQL Connector

Connect to [LibSQL](https://libsql.org/) database.

::alert{type="primary"}
🚀 This connector will be comming soon! Follow up via [unjs/sql0#14](https://github.com/unjs/sql0/issues/14).
::

```js
import { createDB, sql } from "sql0";
import vercelPostgres from "sql0/connectors/libsql";

const db = createDB(
libsql({
/* options */
})
);
```
22 changes: 22 additions & 0 deletions docs/content/100.connectors/planetscale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
navigation.title: PlanetScale
---

# PlanetScale Connector

Connect to [Planetscale](https://planetscale.com/) database.

::alert{type="primary"}
🚀 This connector will be comming soon! Follow up via [unjs/sql0#4](https://github.com/unjs/sql0/issues/4).
::

```js
import { createDB, sql } from "sql0";
import planetscale from "sql0/connectors/planetscale";

const db = createDB(
planetscale({
/* options */
})
);
```
44 changes: 44 additions & 0 deletions docs/content/100.connectors/postgresql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
navigation.title: PostgreSQL
---

# PostgreSQL Connector

## Usage

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

::code-group

```sh [npm]
npm install pg@8 @types/pg@8
```

```sh [Yarn]
yarn add pg@8 @types/pg@8
```

```sh [pnpm]
pnpm add pg@8 @types/pg@8
```

::

```js
import { createDB, sql } from "sql0";
import postgresql from "sql0/connectors/postgresql";

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

## Options

### `url`

Connection URL string.

Alternatively, you can add connection configuration. See [node-postgres](https://node-postgres.com/apis/client#new-client) documentation for more information.
50 changes: 50 additions & 0 deletions docs/content/100.connectors/sqlite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
navigation.title: SQLite
---

# SQLite Connector

## Usage

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

::code-group

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

```sh [Yarn]
yarn add better-sqlite3@8
```

```sh [pnpm]
pnpm add better-sqlite3@8
```

::

```js
import { createDB, sql } from "sql0";
import sqlite from "sql0/connectors/better-sqlite3";

const db = createDB(
sqlite({
/* options */
})
);
```

## Options

### `cwd`

Working directory to create database. Default is current working directory of project. (It will be ignored if `path` is provided an absolute path.)

### `name`

Database (file) name. Default is `db`

### `path`

Related (to `cwd`) or absolute path to the sql file. By default it is stored in `{cwd}/.data/{name}.sqlite3` / `.data/db.sqlite3`
22 changes: 22 additions & 0 deletions docs/content/100.connectors/turso.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
navigation.title: Turso
---

# Turso Connector

Connect to [Turso](https://turso.tech/) database. Follow up via [unjs/sql0#11](https://github.com/unjs/sql0/issues/11).

::alert{type="primary"}
🚀 This connector will be comming soon!
::

```js
import { createDB, sql } from "sql0";
import vercelPostgres from "sql0/connectors/turso";

const db = createDB(
turso({
/* options */
})
);
```
22 changes: 22 additions & 0 deletions docs/content/100.connectors/vercel-postgresql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
navigation.title: Vecel Postgresql
---

# PlanetScale Connector

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

::alert{type="primary"}
🚀 This connector will be comming soon! Follow up via [unjs/sql0#3](https://github.com/unjs/sql0/issues/3).
::

```js
import { createDB, sql } from "sql0";
import vercelPostgres from "sql0/connectors/vercel-postgres";

const db = createDB(
vercelPostgres({
/* options */
})
);
```
42 changes: 42 additions & 0 deletions docs/content/2.usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Usage

Discover how to use `sql0` in your project.

## Installation

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

::code-group

```sh [npm]
npm install sql0
```

```sh [Yarn]
yarn add sql0
```

```sh [pnpm]
pnpm add sql0
```

::

## Usage

```ts
import { createDB, sql } from "sql0";
import sqlite from "sql0/connectors/better-sqlite3";

const db = createDB(sqlite({}));

await db.exec(
"CREATE TABLE IF NOT EXISTS users (id TEXT PRIMARY KEY, firstName TEXT, lastName TEXT, email TEXT)"
);

await db.prepare("INSERT INTO users VALUES (?, 'John', 'Doe', '')").run(id);

const row = await db.prepare("SELECT * FROM users WHERE id = ?").get(id);

console.log(row);
```
7 changes: 7 additions & 0 deletions docs/content/3.http-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# HTTP Server

Expose SQL databases over (secure) HTTP as a restfu API for edge runtimes!

::alert{type="primary"}
🚀 This feature is planned! Follow up [unjs/sql0#6](https://github.com/unjs/sql0/issues/6)
::
7 changes: 7 additions & 0 deletions docs/content/4.custom-connector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Custom Connector

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

Explore [built-in connectors](https://github.com/unjs/sql0/tree/main/src/conectors) to learn how to implement a custom connector.

Always feel free to open an issue to [request new connector](https://github.com/unjs/sql0/issues/new?assignees=&labels=connector&projects=&template=feature-request.yml).
4 changes: 4 additions & 0 deletions docs/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default defineNuxtConfig({
extends: "@nuxt-themes/docus",
modules: ["@nuxtjs/plausible"]
});
16 changes: 16 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "docus-starter",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "nuxi dev",
"build": "nuxi generate",
"generate": "nuxi generate",
"preview": "nuxi preview"
},
"devDependencies": {
"@nuxt-themes/docus": "^1.12.0",
"@nuxtjs/plausible": "^0.2.1",
"nuxt": "^3.5.0"
}
}
Loading

1 comment on commit 16922ac

@vercel
Copy link

@vercel vercel bot commented on 16922ac May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sql0 – ./

sql0-git-main-nuxt-js.vercel.app
sql0.vercel.app
sql0-nuxt-js.vercel.app

Please sign in to comment.