Skip to content

Repository files navigation

@orbitdb/ordered-keyvalue-db

Ordered keyvalue database type for OrbitDB.

Testscodecov

Installation

$ pnpm add @orbitdb/ordered-keyvalue-db

Introduction

A KeyValue database where you can move entries around. Ideal for situations where order is important (e.g., lists of tabs in a spreadsheet, etc.).

Examples

import{useDatabaseType,createOrbitDB}from"@orbitdb/core";import{registerOrderedKeyValue}from"@orbitdb/ordered-keyvalue-db";// Register database type. IMPORTANT - must call before creating orbit instance !useDatabaseType(OrderedKeyValue)constorbit=awaitcreateOrbitDB({ ipfs })constdb=awaitorbit.open({type: "ordered-keyvalue"});awaitdb.put("a","some value");awaitdb.put("b","another value");constall=awaitdb.all();// [{ key: "a", value: "some value", hash: "..." }, { key: "b", value: "another value", hash: "..." }]awaitdb.move("a",1)awaitdb.all();// [{ key: "b", value: "another value", hash: "..." }, { key: "a", value: "some value", hash: "..." }]// You can also specify the position on `put`awaitdb.put("c","goes first",0);awaitdb.all();// [{ key: "c", value: "goes first", hash: "..." }, { key: "b", value: "another value", hash: "..." }, { key: "a", value: "some value", hash: "..." }]

About

Ordered keyvalue database type for orbit-db

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages