# cql.js

> general purpose library for CovenantSQL blockchain

Latest version **0.1.1** (published 2019-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install cql.js
pnpm add cql.js
yarn add cql.js
bun add cql.js
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-01-31 |
| First published | 2019-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8.9 |
| Dependencies | 5 |
| Unpacked size | 272.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | yes |
| Maintainers | chenxi.zhang |
| Keywords | CovenantSQL, database, blockchain, javascript, typescript, web, node, api |

## Links

- npm: https://www.npmjs.com/package/cql.js
- Repository: https://github.com/foreseaz/test
- Homepage: https://github.com/foreseaz/test#readme
- Issues: https://github.com/foreseaz/test/issues
- npm.io page: https://npm.io/package/cql.js

## Dependencies (5)

- [ws](https://npm.io/package/ws.md) ^6.1.2
- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [keyvenant](https://npm.io/package/keyvenant.md) ^0.0.1
- [isomorphic-ws](https://npm.io/package/isomorphic-ws.md) ^4.0.1

## 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.1 (latest) — 2019-01-31
- 0.1.0 — 2019-01-31
- 0.0.2 — 2019-01-24
- 0.0.1 — 2019-01-24

## README

# cql.js

CovenantSQL's client side library

## Install

```
yarn add cql.js
```

or

```
npm i cql.js
```

## Usage

- Use `async` and `await` to handle requests

```javascript
import CQL from 'cql.js'
(async () => {
  // For existing valid websocket endpoint
  // please refer to https://developers.covenantsql.io
  const endpoint = '$COVENANT_BP_WS_ENDPOINT'
  const cql = new CQL(endpoint)

  try {
    await cql.connect()
  } catch (e) {
    console.error(e)
  }

  // connect success
  let status = await cql.bp.getRunningStatus()
  console.log('BP runing status: ', status)
})()
```

- Use promises to handle requests

```javascript
import CQL from 'cql.js'

// For existing valid websocket endpoint
// please refer to https://developers.covenantsql.io
const endpoint = '$COVENANT_BP_WS_ENDPOINT'
const cql = new CQL(endpoint)

cql
  .connect()
  .then(() => {
    // connect success
    cql.bp.getRunningStatus().then(status => {
      console.log('BP runing status: ', status)
    })
  })
  .catch(e => {
    console.error(e)
  })
```

## APIs

- `getProtocolVersion`
- `getRunningStatus`
- `getBlockList`
- `getBlockByHeight`
- `getBlockByHash`
- `getTransactionList`
- `getTransactionListOfBlock`
- `getTransactionByHash`

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