A datastore that can combine multiple stores. Puts and deletes will write through to all datastores. Has and get will try each store sequentially. Query will always try the last one first.

Hierarchy (view full)

Constructors

Properties

stores: Datastore<{}, {}, {}, {}, {}, {}, {}, {}, {}, {}>[]

Methods

  • This will return an object with which you can chain multiple operations together, with them only being executed on calling commit.

    Returns Batch<{}>

    Example

    const b = store.batch()

    for (let i = 0; i < 100; i++) {
    b.put(new Key(`hello${i}`), new TextEncoder('utf8').encode(`hello world ${i}`))
    }

    await b.commit()
    console.log('put 100 values')
  • Remove values for the passed keys

    Parameters

    Returns AsyncIterable<Key>

    Example

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

    for await (const key of store.deleteMany(source)) {
    console.log(`deleted content with key ${key}`)
    }
  • Check for the existence of a value for the passed key

    Parameters

    Returns Promise<boolean>

    Example

    const exists = await store.has(new Key('awesome'))

    if (exists) {
    console.log('it is there')
    } else {
    console.log('it is not there')
    }
  • Store the given key/value pairs

    Parameters

    Returns AsyncIterable<Key>

    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}`)
    }