# orbit-db-counterstore

> Counter store for orbit-db

Latest version **2.0.0** (published 2023-01-18) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install orbit-db-counterstore
pnpm add orbit-db-counterstore
yarn add orbit-db-counterstore
bun add orbit-db-counterstore
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-01-18 |
| First published | 2016-05-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Maintainers | aphelionz, haad, shamb0t, hajamark |
| Keywords | counters, database, orbit-db, orbitdb |

## Links

- npm: https://www.npmjs.com/package/orbit-db-counterstore
- Repository: https://github.com/orbitdb/orbit-db-counterstore
- Issues: https://github.com/orbitdb/orbit-db-counterstore/issues
- npm.io page: https://npm.io/package/orbit-db-counterstore

## Dependencies (1)

- [crdts](https://npm.io/package/crdts.md) ^0.2.0

## Recent versions

- 2.0.0 (latest) — 2023-01-18
- 2.0.1-f77db13.0 (next) — 2023-01-18
- 2.0.1-490309f.0 — 2023-01-18
- 1.12.2-3f123be.0 — 2023-01-11
- 1.12.1 — 2021-11-16
- 1.12.0 — 2020-09-16
- 1.11.0 — 2020-09-11
- 1.10.0 — 2020-09-06
- 1.9.0 — 2020-05-11
- 1.8.0 — 2020-03-10
- 1.7.0 — 2019-12-05
- 1.6.0 — 2019-10-03
- 1.6.0-rc3 — 2019-08-30
- 1.5.2 — 2019-08-30
- 1.6.0-rc2 — 2019-08-30
- … 41 more at https://npm.io/package/orbit-db-counterstore/versions

## README

# orbit-db-counterstore

[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/orbitdb/Lobby) [![Matrix](https://img.shields.io/badge/matrix-%23orbitdb%3Apermaweb.io-blue.svg)](https://riot.permaweb.io/#/room/#orbitdb:permaweb.io) [![Discord](https://img.shields.io/discord/475789330380488707?color=blueviolet&label=discord)](https://discord.gg/cscuf5T)
[![npm version](https://badge.fury.io/js/orbit-db-counterstore.svg)](https://badge.fury.io/js/orbit-db-counterstore)

> Counters database for OrbitDB

A simple counters database. Useful for example counting events separate from data.

Used in [orbit-db](https://github.com/orbitdb/orbit-db).

## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Contribute](#contribute)
  - [Linting](#linting)
- [License](#license)

## Install

This project uses [npm](https://npmjs.com) and [nodejs](https://nodejs.org)

```
npm install orbit-db ipfs
```

## Usage

First, create an instance of OrbitDB:

```javascript
import * as IPFS from 'ipfs'
import OrbitDB from 'orbit-db'

const ipfs = new IPFS()
const orbitdb = OrbitDB.createInstance(ipfs)
```

Get a log database and add an entry to it:

```javascript
const counter = await orbitdb.counter('visitors')
await counter.inc()
console.log(counter.value)
// 1
await counter.inc(4)
console.log(counter.value)
// 5
```

Later, when the database contains data, load the history and query when ready:

```javascript
const counter = await orbitdb.counter('visitors')
counter.events.on('ready', () => {
  await counter.inc()
  console.log(counter.value)
  // 6
})
```

See [example/index.html](https://github.com/orbitdb/orbit-db-counterstore/blob/master/example/index.html) for a detailed example. Note that to run this example, you need to have a local [IPFS daemon](https://dist.ipfs.io/go-ipfs/floodsub-2) [running](https://ipfs.io/docs/getting-started/) at port 5001.

## API

See [OrbitDB's API Documentation](https://github.com/orbitdb/orbit-db/blob/master/API.md#countername) for full details.

## Contribute

Please, feel free to contribute! Take a look at [the issues](https://github.com/orbitdb/orbit-db-counterstore/issues), and comment on an existing issue or create a new one if you have questions, bugs, or suggestions. For larger PRs, open an issue first if you could - drive-by PRs are also welcomed.

Please abide by the [Code of Conduct](CODE_OF_CONDUCT.md). For more on contributing to OrbitDB, check out the docs in [orbitdb/welcome](https://github.com/orbitdb/welcome).

## License

[MIT](LICENSE) © 2016-2018 Protocol Labs Inc., Haja Networks Oy

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