Class Var<T>Abstract

A single persistent variable.

This internally just uses a storage bucket so the functionality is identical to storage buckets.

You can think of this as just a single entry inside a storage bucket

Type Parameters

  • T

Hierarchy (view full)

Properties

Methods

Properties

bucket: Bucket<T>
key: string

Methods

  • Deletes the key from the database

    Returns Promise<undefined | Entry<T>>

    The deleted entry, or undefined if none

  • Fetches the current value

    Returns Promise<undefined | Entry<T>>

    The entry, or undefined if it did not exist

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

    Parameters

    • 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

    • 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