[go: up one dir, main page]

@orbitdb/set-db
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

@orbitdb/set-db

Set database type for OrbitDB.

orbit-db-set tests codecov

Installation

$ pnpm add @orbitdb/set-db

Introduction

As Set database is like a Feed, but each value can only be present once. Works for primitive types as well as more complex objects.

Examples

A simple example with Set:

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:

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}]

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.1851latest
1.1.1-11c1327.00next

Version History

VersionDownloads (Last 7 Days)Published
1.1.1851
1.1.1-11c1327.00
1.1.08
1.0.20
1.0.10
1.0.1-576bc45.00
1.0.1-ffc7041.00
1.0.1-ee9c60b.00
1.0.03

Package Sidebar

Install

npm i @orbitdb/set-db

Weekly Downloads

862

Version

1.1.1

License

AGPL-3.0-or-later

Unpacked Size

187 kB

Total Files

38

Last publish

Collaborators

  • haad
  • julien.malard
  • aphelionz
  • spauldingsmails