docs: move custom store to GUIDE.md
This commit is contained in:
parent
3177f2c634
commit
2f84c96c9d
26
GUIDE.md
26
GUIDE.md
@ -19,6 +19,7 @@ This guide is still being worked on and we would love to get [feedback and sugge
|
|||||||
- [Get an entry](#get-an-entry)
|
- [Get an entry](#get-an-entry)
|
||||||
- [Persistency](#persistency)
|
- [Persistency](#persistency)
|
||||||
- [Replicating a database](#replicating-a-database)
|
- [Replicating a database](#replicating-a-database)
|
||||||
|
- [Custom Database Stores](#custom-stores)
|
||||||
|
|
||||||
## Background
|
## Background
|
||||||
|
|
||||||
@ -350,6 +351,31 @@ ipfs1.on('ready', async () => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Custom Stores
|
||||||
|
|
||||||
|
Use a custom store to implement case specifc functionality that is not supported by the default OrbitDB database stores. Then, you can easily add and use your custom store with OrbitDB:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// define custom store type
|
||||||
|
class CustomStore extends DocumentStore {
|
||||||
|
constructor (ipfs, id, dbname, options) {
|
||||||
|
super(ipfs, id, dbname, options)
|
||||||
|
this._type = CustomStore.type
|
||||||
|
}
|
||||||
|
|
||||||
|
static get type () {
|
||||||
|
return 'custom'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add custom type to orbitdb
|
||||||
|
OrbitDB.addDatabaseType(CustomStore.type, CustomStore)
|
||||||
|
|
||||||
|
// instantiate custom store
|
||||||
|
let orbitdb = new OrbitDB(ipfs, dbPath)
|
||||||
|
let store = orbitdb.create(name, CustomStore.type)
|
||||||
|
```
|
||||||
|
|
||||||
## More information
|
## More information
|
||||||
|
|
||||||
Is this guide missing something you'd like to understand or found an error? Please [open an issue](https://github.com/orbitdb/orbit-db/issues) and let us know what's missing!
|
Is this guide missing something you'd like to understand or found an error? Please [open an issue](https://github.com/orbitdb/orbit-db/issues) and let us know what's missing!
|
||||||
|
27
README.md
27
README.md
@ -21,7 +21,7 @@ OrbitDB provides various types of databases for different data models and use ca
|
|||||||
- **[docs](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbdocsnameaddress-options)**: a document database to which JSON documents can be stored and indexed by a specified key. Useful for building search indices or version controlling documents and data.
|
- **[docs](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbdocsnameaddress-options)**: a document database to which JSON documents can be stored and indexed by a specified key. Useful for building search indices or version controlling documents and data.
|
||||||
- **[counter](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbcounternameaddress)**: Useful for counting events separate from log/feed data.
|
- **[counter](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbcounternameaddress)**: Useful for counting events separate from log/feed data.
|
||||||
|
|
||||||
All databases are [implemented](https://github.com/orbitdb/orbit-db-store) on top of [ipfs-log](https://github.com/orbitdb/ipfs-log), an immutable, operation-based conflict-free replicated data structure (CRDT) for distributed systems.
|
All databases are [implemented](https://github.com/orbitdb/orbit-db-store) on top of [ipfs-log](https://github.com/orbitdb/ipfs-log), an immutable, operation-based conflict-free replicated data structure (CRDT) for distributed systems. If none of the OrbitDB database types match your needs and/or you need case-specific functionality, you can easily [implement and use a custom database store](https://github.com/orbitdb/orbit-db/blob/master/GUIDE.md#custom-stores) of your own.
|
||||||
|
|
||||||
#### Project status & support
|
#### Project status & support
|
||||||
This is the Javascript implementation and it works both in **Browsers** and **Node.js** with support for Linux and OS X (Windows is not supported yet). The minimum required version of Node.js is now 8.0.0. To use with older versions of Node.js, we provide an ES5-compatible build through the npm package, located in `dist/es5/` when installed through npm.
|
This is the Javascript implementation and it works both in **Browsers** and **Node.js** with support for Linux and OS X (Windows is not supported yet). The minimum required version of Node.js is now 8.0.0. To use with older versions of Node.js, we provide an ES5-compatible build through the npm package, located in `dist/es5/` when installed through npm.
|
||||||
@ -140,31 +140,6 @@ After creating an `OrbitDB` instance , you can access the different data stores.
|
|||||||
|
|
||||||
*For further details, see usage for [kvstore](https://github.com/orbitdb/orbit-db-kvstore#usage), [eventlog](https://github.com/orbitdb/orbit-db-eventstore#usage), [feed](https://github.com/orbitdb/orbit-db-feedstore#usage), [docstore](https://github.com/orbitdb/orbit-db-docstore#usage) and [counter](https://github.com/orbitdb/orbit-db-counterstore#usage).*
|
*For further details, see usage for [kvstore](https://github.com/orbitdb/orbit-db-kvstore#usage), [eventlog](https://github.com/orbitdb/orbit-db-eventstore#usage), [feed](https://github.com/orbitdb/orbit-db-feedstore#usage), [docstore](https://github.com/orbitdb/orbit-db-docstore#usage) and [counter](https://github.com/orbitdb/orbit-db-counterstore#usage).*
|
||||||
|
|
||||||
### Custom Store Types
|
|
||||||
|
|
||||||
You can add custom store types to OrbitDB:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// define custom store type
|
|
||||||
class CustomStore extends DocumentStore {
|
|
||||||
constructor (ipfs, id, dbname, options) {
|
|
||||||
super(ipfs, id, dbname, options)
|
|
||||||
this._type = CustomStore.type
|
|
||||||
}
|
|
||||||
|
|
||||||
static get type () {
|
|
||||||
return 'custom'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add custom type to orbitdb
|
|
||||||
OrbitDB.addDatabaseType(CustomStore.type, CustomStore)
|
|
||||||
|
|
||||||
// instantiate custom store
|
|
||||||
let orbitdb = new OrbitDB(ipfs, dbPath)
|
|
||||||
let store = orbitdb.create(name, CustomStore.type)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Install dependencies
|
### Install dependencies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user