Nested key-value database type for OrbitDB.
$ pnpm add @orbitdb/nested-db
As Nested database is like a KeyValue database, but it can contain nested values that can be accessed as JSON.
A simple example with Nested:
import{createOrbitDB,useDatabaseType}from"@orbitdb/core";import{Nested}from"@orbitdb/nested-db";// Register nested database type. IMPORTANT - must call before creating orbit instance !useDatabaseType(Nested);constorbitdb=awaitcreateOrbitDB({ ipfs })constdb=awaitorbitdb.open({type: "nested"});awaitdb.put("a",1);awaitdb.put("b/c",2);awaitdb.put(["b","d"],3)// Alternative syntaxconstall=awaitdb.all();// { a: 1, b: { c: 2, d: 3 }}awaitdb.get("b")// { c: 2, d: 3 }awaitdb.del("b");awaitdb.all();// { "a": 1 }A more complex example with object types:
import{createOrbitDB,useDatabaseType}from"@orbitdb/core";import{Nested}from"@orbitdb/nested-db";// Register nested database type. IMPORTANT - must call before creating orbit instance !useDatabaseType(Nested);constorbit=awaitcreateOrbitDB({ ipfs })constdb=awaitorbitdb.open({type: "nested"});awaitdb.insert({a: {b: 1},d: 3});awaitdb.insert("a",{c: 2});constall=awaitdb.all();// { a: { b: 1, c: 2}, d: 3 }