Interface Datastore<HasOptionsExtension, PutOptionsExtension, PutManyOptionsExtension, GetOptionsExtension, GetManyOptionsExtension, DeleteOptionsExtension, DeleteManyOptionsExtension, QueryOptionsExtension, QueryKeysOptionsExtension, BatchOptionsExtension>

interface Datastore<HasOptionsExtension, PutOptionsExtension, PutManyOptionsExtension, GetOptionsExtension, GetManyOptionsExtension, DeleteOptionsExtension, DeleteManyOptionsExtension, QueryOptionsExtension, QueryKeysOptionsExtension, BatchOptionsExtension> {
    batch(): Batch<BatchOptionsExtension>;
    delete(key, options?): Await<void>;
    deleteMany(source, options?): AwaitIterable<Key>;
    get(key, options?): Await<Uint8Array>;
    getMany(source, options?): AwaitIterable<Pair>;
    has(key, options?): Await<boolean>;
    put(key, val, options?): Await<Key>;
    putMany(source, options?): AwaitIterable<Key>;
    query(query, options?): AwaitIterable<Pair>;
    queryKeys(query, options?): AwaitIterable<Key>;
}

Type Parameters

  • HasOptionsExtension = {}
  • PutOptionsExtension = {}
  • PutManyOptionsExtension = {}
  • GetOptionsExtension = {}
  • GetManyOptionsExtension = {}
  • DeleteOptionsExtension = {}
  • DeleteManyOptionsExtension = {}
  • QueryOptionsExtension = {}
  • QueryKeysOptionsExtension = {}
  • BatchOptionsExtension = {}

Hierarchy (view full)

Implemented by

    Methods

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

      Returns Batch<BatchOptionsExtension>

      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 the record for the passed key

      Parameters

      Returns Await<void>

      Example

      await store.delete(new Key('awesome'))
      console.log('deleted awesome content :(')
    • Retrieve the value stored under the given key

      Parameters

      Returns Await<Uint8Array>

      Example

      const value = await store.get(new Key('awesome'))
      console.log('got content: %s', value.toString('utf8'))
      // => got content: datastore
    • Check for the existence of a value for the passed key

      Parameters

      Returns Await<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 passed value under the passed key

      Parameters

      Returns Await<Key>

      Example

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