Home

Awesome

Kuiper

Additional database types for orbit-db.

Orbit-db Kuiper tests codecov

Deprecation notice

This package is deprecated in favour of the individual packages @orbitdb/feed-db, @orbitdb/set-db and @orbitdb/ordered-keyvalue-db.

Installation

$ pnpm add @constl/orbit-db-kuiper

Introduction

Kuiper brings additional database types to orbit-db.

Examples

Set

As simple example with Set:

import { createOrbit } from "@orbitdb/core";
import { registerAll } from "@constl/orbit-db-kuiper";

// Register Kuiper database types. IMPORTANT - must call before creating orbit instance !
registerAll();

const orbit = await createOrbit({ ipfs })

const db = await orbit.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]

Feed

const db = await orbit.open({ type: "feed" });

await db.add({ a: 1, b: "c" });

const all = await db.all();  // [{ value: { a: 1, b: "c" }, hash: "..." }]

await db.add({ a: 1, b: "c" });
await db.all();  
// [{ value: { a: 1, b: "c" }, hash: "..." }, { value: { a: 1, b: "c" }, hash: "..." }]

OrderedKeyValue


const db = await orbit.open({ type: "ordered-keyvalue" });

await db.put("a", "some value");
await db.put("b", "another value");

const all = await db.all();
// [{ key: "a", value: "some value", hash: "..." }, { key: "b", value: "another value", hash: "..." }]

await db.move("a", 1)

await db.all();
// [{ key: "b", value: "another value", hash: "..." }, { key: "a", value: "some value", hash: "..." }]

// You can also specify the position on `put`
await db.put("c", "goes first", 0);

await db.all();
// [{ key: "c", value: "goes first", hash: "..." }, { key: "b", value: "another value", hash: "..." }, { key: "a", value: "some value", hash: "..." }]