- Notifications
You must be signed in to change notification settings - Fork0
Nested key-value database for OrbitDB
License
NotificationsYou must be signed in to change notification settings
orbitdb/nested-db
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Nested key-value database type for OrbitDB.
$ pnpm add @orbitdb/nested-dbAsNested database is like aKeyValue database, but it can contain nested values that can be accessed as JSON.
A simple example withNested:
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}
About
Nested key-value database for OrbitDB
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published