A blockstore backed by the file system

Implements

Constructors

Properties

createIfMissing: boolean
deleteManyConcurrency: number
errorIfExists: boolean
getManyConcurrency: number
path: string
putManyConcurrency: number
shardingStrategy: ShardingStrategy

Methods

  • Remove the record for the passed key

    Parameters

    Returns Promise<void>

    Example

    await store.delete(new Key('awesome'))
    console.log('deleted awesome content :(')
  • Remove values for the passed keys

    Parameters

    Returns AsyncIterable<CID<unknown, number, number, Version>>

    Example

    const source = [new Key('awesome')]

    for await (const key of store.deleteMany(source)) {
    console.log(`deleted content with key ${key}`)
    }
  • Retrieve the value stored under the given key

    Parameters

    Returns Promise<Uint8Array>

    Example

    const value = await store.get(new Key('awesome'))
    console.log('got content: %s', value.toString('utf8'))
    // => got content: datastore
  • Retrieve all cid/block pairs from the blockstore as an unordered iterable

    Returns AsyncIterable<Pair>

    Example

    for await (const { multihash, block } of store.getAll()) {
    console.log('got:', multihash, block)
    // => got MultihashDigest('Qmfoo') Uint8Array[...]
    }
  • Retrieve values for the passed keys

    Parameters

    Returns AsyncIterable<Pair>

    Example

    for await (const { key, value } of store.getMany([new Key('awesome')])) {
    console.log(`got "${key}" = "${new TextDecoder('utf8').decode(value)}"`')
    // => got "/awesome" = "datastore"
    }
  • Store the given key/value pairs

    Parameters

    Returns AsyncIterable<CID<unknown, number, number, Version>>

    Example

    const source = [{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }]

    for await (const { key, value } of store.putMany(source)) {
    console.info(`put content for key ${key}`)
    }