docs: Show how to use database modules for db customization.

This commit is contained in:
Hayden Young 2023-06-30 20:13:59 +01:00
parent 745af170c4
commit 208e9776e3
2 changed files with 8 additions and 13 deletions

View File

@ -2,20 +2,14 @@
* @namespace Databases-Documents
* @memberof module:Databases
* @description Documents database.
* @example <caption>Create documents db with default options</caption>
* import { create } from 'IPFS'
*
* const ipfs = create()
* const Partial = Documents()
* const documents = await Partial({ ipfs })
* @example <caption>Create documents db with custom index</caption>
* import { create } from 'IPFS'
* import { OrbitDB, Documents } from 'orbit-db'
*
* const ipfs = create()
* const options = { indexBy: 'myCustomId'}
* const Partial = Documents(options)
* const documents = await Partial({ ipfs })
*
* const orbitdb = await OrbitDB({ ipfs })
* const db = await orbitdb.open('my-docs', { Database: Documents({ indexBy: 'myCustomId'} ) }
*
* @augments module:Databases~Database
*/
import Database from '../database.js'

View File

@ -7,11 +7,12 @@
* Key-value pairs are stored to the configured storage.
* @example <caption>Specify a custom storage</caption>
* import { create } from 'IPFS'
* import { OrbitDB, KeyValueIndexed, IPFSBlockStorage } from 'orbit-db'
*
* const ipfs = create()
* const storage = await IPFSBlockStorage()
* const Partial = KeyValueIndexed({ storage })
* const keyValueIndexed = await Partial({ ipfs })
* const storage = await IPFSBlockStorage({ ipfs })
* const orbitdb = await OrbitDB({ ipfs })
* const db = await orbitdb.open('my-kv', { Database: KeyValueIndexed({ storage }) })
*
* @augments module:Databases~Database
* @augments module:Databases.Databases-KeyValue