Note: this is a pretty experimental package, it's unclear if this is actually useful - I intended this as a way of sharing hypercore keys between devices, but there are probably better solutions for this now.
npm i hyperdb-storage
const hyperdb =const storage =// This hyperdb is stored on disk.const db =// This hyperdb is stored inside the hyperdb `db`.// All of its contents are stored under the prefix 'example-db'.const nestedDb =// You can also store other hyper*-structures...const nestedFeed =// ...or store a Dat inside a hyperdb.const nestedDat =
dbis an instance of hyperdb.
prefixis a string. All 'files' will be stored under this prefix.
storageOverridesis an optional object which maps the SLEEP file names to storage providers.
A storage provider is either a string defining the directory where you want to store files, or a function which takes a filename string and returns a random-access-storage instance.
Example:// The metadata for this hyperdb is stored inside `db`, but the data files are// stored on disk, and the secret keys are stored in the system keychain.const keychain =const exampleDb =
Important: You need to be careful with conflicts in the parent db if you have granted write access to multiple keys. You should use the conflict resolution options in the
hyperdb constructor, eg:
If you don't use either of these, and more than one node is found for a given key, this module will emit a warning and use the first node.
MIT © 2018 harry lachenmayer