Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Methods

  • batch(): Batch<Key, Value>
  • This will return an object with which you can chain multiple operations together, with them only being executed on calling commit.

    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')

    Returns Batch<Key, Value>

  • close(): Promise<void>
  • Returns Promise<void>

  • delete(key: Key, options?: Options): Promise<void>
  • Remove the record for the passed key

    example
    await store.delete(new Key('awesome'))
    console.log('deleted awesome content :(')

    Parameters

    Returns Promise<void>

  • Remove values for the passed keys

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

    for await (const key of store.deleteMany(source)) {
    console.log(`deleted content with key ${key}`)
    }

    Parameters

    Returns AsyncIterable<Key>

  • get(key: Key, options?: Options): Promise<Value>
  • Retrieve the value stored under the given key

    example
    const value = await store.get(new Key('awesome'))
    console.log('got content: %s', value.toString('utf8'))
    // => got content: datastore

    Parameters

    Returns Promise<Value>

  • Retrieve values for the passed keys

    example
    for await (const value of store.getMany([new Key('awesome')])) {
    console.log('got content:', new TextDecoder('utf8').decode(value))
    // => got content: datastore
    }

    Parameters

    Returns AsyncIterable<Value>

  • has(key: Key, options?: Options): Promise<boolean>
  • Check for the existence of a value for the passed key

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

    if (exists) {
    console.log('it is there')
    } else {
    console.log('it is not there')
    }

    Parameters

    Returns Promise<boolean>

  • open(): Promise<void>
  • Returns Promise<void>

  • put(key: Key, val: Value, options?: Options): Promise<void>
  • Store the passed value under the passed key

    example
    await store.put([{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }])
    

    Parameters

    • key: Key
    • val: Value
    • Optional options: Options

    Returns Promise<void>

  • Store the given key/value pairs

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

    Parameters

    Returns AsyncIterable<Pair<Key, Value>>

  • Query the store.

    example
    // retrieve __all__ key/value pairs from the store
    let list = []
    for await (const { key, value } of store.query({})) {
    list.push(value)
    }
    console.log('ALL THE VALUES', list)

    Parameters

    Returns AsyncIterable<Pair<Key, Value>>

  • Query the store.

    example
    // retrieve __all__ keys from the store
    let list = []
    for await (const key of store.queryKeys({})) {
    list.push(key)
    }
    console.log('ALL THE KEYS', key)

    Parameters

    Returns AsyncIterable<Key>

Generated using TypeDoc