# db3.js

> DB3 Network Javascript API

Latest version **0.4.6** (published 2023-08-09) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install db3.js
pnpm add db3.js
yarn add db3.js
bun add db3.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.4.6 |
| Published | 2023-08-09 |
| First published | 2023-01-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 2.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | dbpunk labs |
| Maintainers | db3_dev |
| Keywords | db, database, db3, document, indexeddb, encryption, couchdb, live-query, reactive, replication, realtime |

## Links

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

## Dependencies (6)

- [viem](https://npm.io/package/viem.md) ^0.3.50
- [db3-bson](https://npm.io/package/db3-bson.md) 5.1.2
- [@noble/secp256k1](https://npm.io/package/@noble/secp256k1.md) ^1.7.0
- [@protobuf-ts/runtime](https://npm.io/package/@protobuf-ts/runtime.md) ^2.8.2
- [@protobuf-ts/runtime-rpc](https://npm.io/package/@protobuf-ts/runtime-rpc.md) ^2.8.2
- [@protobuf-ts/grpcweb-transport](https://npm.io/package/@protobuf-ts/grpcweb-transport.md) ^2.8.2

## Recent versions

- 0.4.6 (latest) — 2023-08-09
- 0.4.1 — 2023-07-26
- 0.4.0 — 2023-07-25
- 0.3.18 — 2023-07-24
- 0.3.17 — 2023-07-04
- 0.3.15 — 2023-06-29
- 0.3.14 — 2023-06-28
- 0.3.13 — 2023-06-26
- 0.3.11 — 2023-06-23
- 0.3.10 — 2023-06-22
- 0.3.9 — 2023-06-21
- 0.3.1 — 2023-06-19
- 0.2.28 — 2023-05-31
- 0.2.27 — 2023-05-30
- 0.2.27-dev — 2023-05-04
- … 20 more at https://npm.io/package/db3.js/versions

## README

# What is db3.js
![GitHub release (latest by date)](https://img.shields.io/github/v/release/dbpunk-labs/db3.js?color=green&display_name=tag&label=db3.js&logo=db3&logoColor=https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F102341693%3Fs%3D96%26v%3D4&style=flat-square)
![npm](https://img.shields.io/npm/dw/db3.js?style=flat-square)
[![Coveralls branch](https://img.shields.io/coverallsCoverage/github/dbpunk-labs/db3.js?style=flat-square)](https://coveralls.io/github/dbpunk-labs/db3.js)

db3.js is the [db3 network](https://github.com/dbpunk-labs/db3) javascript API and you can use it to write and query JSON documents against the db3 network.
and you can build fully decentralized applications combining [web3.js](https://github.com/web3/web3.js) and db3.js

# Getting Started

## Install db3.js

```
yarn add db3.js
```

## Quick Started

```typescript
// create a account
const account = createRandomAccount()
// create the client from db3 cloud sandbox
const client = createClient('https://rollup.cloud.db3.network',
                            'https://index.cloud.db3.network',
                             account)
await syncAccountNonce(client)
// get the collection
const collection = await getCollection("0x6ef32f0d8fc6bc872ffa977eb80920a0a75d0206", "book", client)
// add a document
const {id} = await addDoc(collection, {
                name:"The Three-Body Problem",
                author:"Cixin-Liu",
                rate:"4.8"} as Book)
console.log(id)
// query the document
const resultSet = await queryDoc<Book>(collection, "/[author=Cixin-Liu]")
```

<img width="500px" src="./statics/quick_started.png" align="center"/>

[Try on codesandbox](https://codesandbox.io/s/db3-js-helloword-447nxd?file=/src/App.tsx:673-710)


## Examples

* [build a query api based on db3 and vercel function](https://github.com/dbpunk-labs/db3_vercel_query)
* [build curd example based on db3 ,express and typescript](https://github.com/dbpunk-labs/db3_express_typescript_example)

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