# cql-js-driver

> A javascript driver for covenantsql run in web

Latest version **0.1.0** (published 2019-05-31) · 0 weekly downloads

## Install

```sh
npm install cql-js-driver
pnpm add cql-js-driver
yarn add cql-js-driver
bun add cql-js-driver
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2019-05-31 |
| First published | 2019-05-31 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >= 0.6 |
| Dependencies | 3 |
| Unpacked size | 110.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | chenxi.zhang |
| Keywords | CovenantSQL, driver, nodejs, database, blockchain, typescript |

## Links

- npm: https://www.npmjs.com/package/cql-js-driver
- npm.io page: https://npm.io/package/cql-js-driver

## Dependencies (3)

- [sql92-string](https://npm.io/package/sql92-string.md) ^1.0.1
- [whatwg-fetch](https://npm.io/package/whatwg-fetch.md) ^3.0.0
- [@types/whatwg-fetch](https://npm.io/package/@types/whatwg-fetch.md) ^0.0.33

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2019-05-31

## README

# cql-js-driver

This repo is javascript lib to interact with [CovenantSQL](https://github.com/CovenantSQL/CovenantSQL) local proxy.

## Install

Install `cql-js-driver` via npm or yarn:
```bash
npm install --save cql-js-driver
```
or
```bash
yarn add cql-js-driver
```

## Get started
Follow CovenantSQL [Quickstart](https://testnet.covenantsql.io/quickstart) to get you prepared.

### use testnet proxy directly

We provides testnet proxy for your testing: `http(s)://testnet-proxy.covenantsql.io`

```javascript
const config = {
    endpoint: 'https://testnet-proxy.covenantsql.io',
    dbid: `${DB_ID}`, // your DB id created by `cql` tools
}
```

### if you setup your own proxy

1. set up CovenantSQL local proxy

```bash
$ go get github.com/CovenantSQL/CovenantSQL
$ make bin/cql
$ rsync -avP ./conf/testnet/{config.yaml,private.key} ~/.cql/
$ ./bin/cql -adapter 127.0.0.1:6000
```

2. fill in the configs

```javascript
const config = {
    endpoint: 'localhost:6000', // local testnet endpoint without https
    dbid: `${DB_ID}`, // your DB id created by `cql` tools
}
```

### connect and query
```typescript
import cql from 'cql-js-driver'

const config = {...} // see above

cql.createConnection(config).then(async (connection: any) => {
    // read
    const data1 = await connection.query("select ? + ?", [2.1, 3.2]);
    console.log(data1);

    // write
    const createTableSQL = `
    CREATE TABLE IF NOT EXISTS contacts (\
    contact_id INTEGER PRIMARY KEY,
    first_name TEXT NOT NULL,
    last_name TEXT NOT NULL,
    email text NOT NULL UNIQUE,
    phone text NOT NULL UNIQUE
    );
    `
    const status1 = await connection.exec(createTableSQL)
    console.log(`exec1 status:`, status1);

    const data2 = await connection.query("show tables;");
    console.log(data2);
}).catch((e: any) => console.log(e))
```

## Contribution

- `yarn dev`
- open `http://localhost:8080/examples/`

## License

[Apache-2.0](LICENSE).

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