# @asdine/genji

> Document-oriented, embedded, SQL database

Latest version **0.1.0-alpha** (published 2020-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @asdine/genji
pnpm add @asdine/genji
yarn add @asdine/genji
bun add @asdine/genji
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha |
| Published | 2020-04-09 |
| First published | 2020-04-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 3.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1704 |
| Author | Asdine El Hrychy |
| Maintainers | asdine |

## Links

- npm: https://www.npmjs.com/package/@asdine/genji
- Repository: git@github.com:asdine/genji.js
- npm.io page: https://npm.io/package/@asdine/genji

## Recent versions

- 0.1.0-alpha (latest) — 2020-04-09

## README

<h1 align="center"> Genji.js </h1>
<p align="center">
  <a href="https://genji.dev">
    <img alt="Genji" title="Genji" src="https://raw.githubusercontent.com/asdine/genji/master/docs/assets/icons/logo.svg?sanitize=true" width="100">
  </a>
</p>

<p align="center">
  Document-oriented, embedded, SQL database
</p>

Experimental wrapper around the [Genji](https://github.com/asdine/genji) database.

It's functional but, currently, the compiled WebAssembly file is too big (~3mb) to be objectively usable in production.

The code is compatible with [TinyGo](https://github.com/tinygo-org/tinygo) and produces a 400kb wasm file but there are too many bugs in the v0.12.0, I will wait for the next version to give a try.

## Getting started

Install Genji

```bash
yarn add @asdine/genji
```

Copy the wasm file from `node_modules` into your public directory

```bash
cp node_modules/@asdine/genji/genji.wasm public/
```

Or if you are using Webpack, add this to your config, after installing the `copy-webpack-plugin` loader :

```bash
yarn add --dev copy-webpack-plugin
```

```javascript
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    ...
    plugins: [
        new CopyWebpackPlugin([
            { from: 'node_modules/@asdine/genji/dist/genji.wasm' }
        ])
    ]
}
```

## Usage

```javascript
import { initDatabase } from '@asdine/genji';

async function run() {
    const genji = await initDatabase();
    const db = await genji.Database();
    await db.exec("CREATE TABLE foo");
    await db.exec("INSERT INTO foo (a) VALUES (1), (2), (3)");

    db.query("SELECT * FROM foo").
        forEach((v) => console.log(v));
}

run()
```

## Build from source

Requires [Go](https://golang.org/dl/) >= 1.13 and [Node](https://nodejs.org/en/download/) >= 10

```bash
yarn install
yarn build
```

## Running tests

```bash
yarn test
```

---
_Source: https://npm.io/package/@asdine/genji · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
