Ordered keyvalue database type for OrbitDB.
$ pnpm add @orbitdb/ordered-keyvalue-db
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.).
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: "..." }]