# @orbitdb/set-db

> Set database type for orbit-db.

Latest version **2.2.1** (published 2026-09-30) · AGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @orbitdb/set-db
pnpm add @orbitdb/set-db
yarn add @orbitdb/set-db
bun add @orbitdb/set-db
```

## Health

**Score 70/100 (B)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2026-09-30 |
| First published | 2024-01-25 |
| Weekly downloads | 0 |
| License | AGPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 230.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Julien Jean Malard-Adam |
| Maintainers | haad, julien.malard, spauldingsmails |
| Keywords | orbitdb |

## Links

- npm: https://www.npmjs.com/package/@orbitdb/set-db
- npm.io page: https://npm.io/package/@orbitdb/set-db

## Dependencies (3)

- [helia](https://npm.io/package/helia.md) ^7.1.15
- [@orbitdb/core](https://npm.io/package/@orbitdb/core.md) 4.0.0
- [tiny-typed-emitter](https://npm.io/package/tiny-typed-emitter.md) ^2.1.0

## Recent versions

- 2.2.1 (latest) — 2026-09-30
- 1.1.1-11c1327.0 (next) — 2024-10-30
- 2.2.0 — 2026-09-30
- 2.1.2 — 2026-07-06
- 2.1.1 — 2026-04-22
- 2.1.0 — 2026-04-22
- 2.0.1 — 2025-07-21
- 2.0.0 — 2025-07-13
- 1.2.1 — 2025-07-07
- 1.2.0 — 2025-07-07
- 1.1.6 — 2025-07-07
- 1.1.5 — 2025-07-04
- 1.1.4 — 2025-06-23
- 1.1.3 — 2025-06-19
- 1.1.2 — 2025-02-21
- … 8 more at https://npm.io/package/@orbitdb/set-db/versions

## README

# @orbitdb/set-db
Set database type for OrbitDB.

[![orbit-db-set tests](https://github.com/orbitdb/set-db/actions/workflows/run-test.yml/badge.svg?branch=main)](https://github.com/orbitdb/set-db/actions/workflows/run-test.yml)
[![codecov](https://codecov.io/gh/orbitdb/set-db/graph/badge.svg?token=7OZK4BJDej)](https://codecov.io/gh/orbitdb/set-db)

## Installation
```
$ pnpm add @orbitdb/set-db
```
## Introduction
As `Set` database is like a [`Feed`](https://github.com/reseau-constellation/set), but each value can only be present once. Works for primitive types as well as more complex objects.

## Examples

A simple example with `Set`:
```ts
import { createOrbitDB } from "@orbitdb/core";
import { registerSet } from "@orbitdb/set-db";

// Register set database type. IMPORTANT - must call before creating orbit instance !
registerSet();

const orbitdb = await createOrbitDB({ ipfs })

const db = await orbitdb.open({ type: "set" });

await db.add(1);
await db.add(2);

const all = await db.all();  // [1, 2]

await db.add(1);
await db.all()  // Yay !! Still [1, 2]
```

As more complex example with object types:
```ts
import { createOrbitDB } from "@orbitdb/core";
import { registerSet } from "@orbitdb/set-db";

// Register set database type. IMPORTANT - must call before creating orbit instance !
registerSet();

const orbit = await createOrbitDB({ ipfs })

const db = await orbitdb.open({ type: "set" });

await db.add({a: 1});
await db.add({a: 2});

const all = await db.all();  // [{a: 1}, {a: 2}]

await db.add({a: 1});
await db.all()  // Yay !! Still [{a: 1}, {a: 2}]
```

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