Namespace: Databases-KeyValueIndexed

Databases.Databases-KeyValueIndexed

Key-Value database that uses an index in order to provide fast queries.

Key-value pairs are stored to the configured storage.

Source:

Example

Specify a custom storage

import { createHelia } from 'helia'
import { createOrbitDB, KeyValueIndexed, IPFSBlockStorage } from 'orbitdb'

const ipfs = createHelia()
const storage = await IPFSBlockStorage({ ipfs })
const orbitdb = await createOrbitDB({ ipfs })
const db = await orbitdb.open('my-kv', { Database: KeyValueIndexed({ storage }) })

Extends

Methods

(async) get(key) → {*}

Gets a value from the store by key.

Parameters:
Name Type Description
key string

The key of the value to get.

Source:
Returns:

The value corresponding to key or null.

Type
*

(async, generator) iterator(filtersopt)

Iterates over keyvalue pairs.

Parameters:
Name Type Attributes Default Description
filters Object <optional>
{}

Various filters to apply to the iterator.

Properties
Name Type Attributes Default Description
amount string <optional>
-1

The number of results to fetch.

Source:
Yields:
[string, string, string] The next key/value as key/value/hash.