Documents database.
- Source:
Example
import { createHelia } from 'helia'
import { createOrbitDB, Documents } from 'orbitdb'
const ipfs = createHelia()
const orbitdb = await createOrbitDB({ ipfs })
const db = await orbitdb.open('my-docs', { Database: Documents({ indexBy: 'myCustomId'} ) }
Extends
Methods
(async) all()
Returns all documents.
- Source:
Returns:
[][string, string, string] An array of documents as hash/key value entries.
(async) del(key) → {string}
Deletes a document from the store.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key of the doc to delete. |
- Source:
Returns:
The hash of the new oplog entry.
- Type
- string
(async) get(key) → {Object}
Gets a document from the store by key.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key of the doc to get. |
- Source:
Returns:
The doc corresponding to key or null.
- Type
- Object
(async, generator) iterator(filtersopt)
Iterates over documents.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filters |
Object |
<optional> |
{} | Various filters to apply to the iterator. Properties
|
- Source:
Yields:
(async) put(doc) → {string}
Stores a document to the store.
Parameters:
Name | Type | Description |
---|---|---|
doc |
Object | An object representing a key/value list of fields. |
- Source:
Returns:
The hash of the new oplog entry.
- Type
- string
(async) query(findFn) → {Array}
Queries the document store for documents matching mapper filters.
Parameters:
Name | Type | Description |
---|---|---|
findFn |
function | A function for querying for specific results. The findFn function's signature takes the form |
- Source:
Returns:
Found documents.
- Type
- Array