Pre release (#85)

* docs: Update README to match new version.

* docs: Update events example to use new API.

* docs: Correctly print out db query results.

* test: Remove concurrent.

* test: Remove unimplemented and 3rd party AC tests.

* test: Remove unimplemented and 3rd party identity tests.

* docs: Move jsdoc config to conf directory.

* Point package.json main at index.js to access all exported functions.

* docs: Vetted AC docs; these examples should work if implemented in code. Explicitly show orbit-db function imports.

* docs: Fix incorrectly declared write objects.

* docs: Improved canAppend documentation. Better JS syntax highlighting.

* docs: wss and define filters for localhost separately.

* docs: Simplified webSockets implementation with filters.

* docs: Return manifest json only (no hash). JS highlighting.

* docs: Remove operations documentation.

* docs: Update heading levels.

* docs: Differentiate between db types which expose put/add function.

* docs: Correctly import IPFS and pass config.

* docs: A simple method for full db replication.

* docs: Link to existing examples of db implementation.

* docs: Update heading.

* docs: JS code formatting. import statements.

* docs: Expand on the concepts of identities and identity management.

* docs: Describe head sync-ing and full replication.

* docs: Comprehensive explanation of setting up a db and sync-ing/replicating data across peers. Examples can be run in node.js.

* docs: Syntax highlighting. Correct code implementation for custom/3rd party storage implementations.

* docs: Getting started cleanup.

* docs: Manifest as an IPLD data strcture.
This commit is contained in:
Hayden Young
2023-06-18 02:13:54 +08:00
committed by GitHub
parent 0c01bd22b7
commit 85e6848f4c
7 changed files with 502 additions and 172 deletions

View File

@@ -2,6 +2,8 @@
OrbitDB is all about storage, and storage can be configured to best meet the needs of the implementation. Storage is also designed to be hierarchical, allowing for a variety of storage mechanisms to be used together.
Which storage strategy is chosen depends on the requirements of the application. OrbitDB's storage customization allows for trade-offs between memory usage and speed.
## Storage types
OrbitDB is bundled with the following storage:
@@ -10,7 +12,7 @@ OrbitDB is bundled with the following storage:
- LevelStorage: LevelDB-based storage,
- LRUStorage: A Least Recently Used cache,
- MemoryStorage: A memory only array,
- ComposedStorage: A storage mechanism combining two other storage objects.
- ComposedStorage: Combines two storages, eg. LRUStorage and IPFSBlockStorage.
All storage objects expose two common functions, `put` for adding a record and `get` for retrieving a record. This allows for storage to be easily swapped in and out based on the needs of the database solution.
@@ -20,7 +22,7 @@ ComposedStorage combines two of the above storage objects. This reduces the need
To use composed storage, create two storage objects and then pass them to an instance of `ComposedStorage`:
```
```js
const memoryStorage = await MemoryStorage()
const levelStorage = await LevelStorage()
@@ -31,27 +33,26 @@ The order in which primary storage is passed to ComposedStorage is important. Wh
## Customizing Storage
By default, OrbitDB uses `ComposedStorage`, but storage can be customized across most functionality. For example, to permanently store database operations in OpLog, the default `MemoryStorage` can be replaced with `LevelStorage`:
To override OrbitDB's default storage, alternative storages can be specified when a database is opened:
```
const identities = await Identities()
const identity = identities.createIdentity({ id: 'userA' })
```js
const entryStorage = await MemoryStorage()
const headsStorage = await MemoryStorage()
const indexStorage = await MemoryStorage()
const log = await Log(identity, { entryStorage, headsStorage, indexStorage })
await log.append('An operation')
const db = await orbitdb.open('my-db', { entryStorage, headsStorage })
```
## Implementing a third party storage solution
Any storage mechanism can be used with OrbitDB provided it implements the OrbitDB storage interface. Once created, simply pass the storage instance to OrbitDB:
```
const identities = await Identities()
const identity = identities.createIdentity({ id: 'userA' })
```js
// Perhaps some kind of locally developed storage implementation.
import CustomStorage from './custom-storage.js'
const entryStorage = await CustomStorage()
const headsStorage = await CustomStorage()
const indexStorage = await CustomStorage()
const log = await Log(identity, { entryStorage, headsStorage, indexStorage })
const db = await orbitdb.open('my-db', { entryStorage, headsStorage, indexStorage })
```
See the [various storage implementations](../src/storage) to see how custom storage should be structured for compatibility with OrbitDB.