Class JsonBucket<T>

A Bucket holding json objects

{@see } Bucket for more info on buckets.

Type Parameters

  • T

Hierarchy (view full)

Properties

name: string
pluginId: null | string

Methods

  • Counts the number of entries in a bucket (optionally filtering by pattern).

    Parameters

    • Optional keyPattern: string

      Optional key pattern to filter by

      • %: A percent sign (%) matches any sequence of zero or more characters.
      • _: An underscore (_) matches any single character.

      To match _ and % as literals escape them with backslash (\_ and \%).

    Returns Promise<number>

    Number of entries

  • Deletes an entry from the bucket permanently.

    Parameters

    • key: string

      The key to delete

    Returns Promise<undefined | Entry<T>>

    The deleted entry, or undefined if none

  • Deletes all entries (optionally filtering by pattern) permanently.

    Parameters

    • Optional keyPattern: string

      Optional key pattern to filter by

      • %: A percent sign (%) matches any sequence of zero or more characters.
      • _: An underscore (_) matches any single character.

      To match _ and % as literals escape them with backslash (\_ and \%).

    Returns Promise<number>

    Number of deleted entries

  • Fetches a entry from the bucket.

    Parameters

    • key: string

      The key for the value you want returned

    Returns Promise<undefined | Entry<T>>

    The entry, or undefined if it did not exist

  • Retrieve a list of entries from the database, you can use after to paginate through all the items in the bucket.

    Parameters

    Returns Promise<Entry<T>[]>

    A list of entries

  • Store a value at the provided key in the bucket, this will overwrite the previous value stored there, if any.

    Parameters

    • key: string

      The key that you're storing the value in

    • value: T

      The value you're storing, for objects this will be converted to json behind the scenes

    • Optional options: SetValueOptions

      Optional options

    Returns Promise<Entry<T>>

    The storage entry

  • Similar to set but stores the value conditionally.

    Parameters

    • key: string

      The key where you're storing the value

    • value: T

      The value you're storing, for objects this will be converted to json behind the scenes

    • cond: "IfExists" | "IfNotExists"

      The condition that has to pass to store the value.

      • IfExists: will only store the value if the key existed beforehand.
      • IfNotExists: will only store the value if the key did not exist.
    • Optional options: SetValueOptions

      Optional options

    Returns Promise<undefined | Entry<T>>

    Either the new entry, or undefined if the condition failed.

Generated using TypeDoc