Skip to main content

Variable: Flashcore

const Flashcore: object;

Built-in KV database for long-term storage.

import { Flashcore } from 'robo.js'

await Flashcore.set('key', 'value')
const value = await Flashcore.get('key')
await Flashcore.delete('key')

Use this to store and retrieve data across sessions. All APIs are asynchronous. Defaults to file-based storage, but can be configured to use other engines using Keyv adapters.

Learn more: Flashcore Database

Type declaration

clear()

clear: () => boolean | void | Promise<boolean> | Promise<void>;

Clears all key-value pairs from the store.

Returns

boolean | void | Promise<boolean> | Promise<void>

  • Resolves to a boolean indicating whether the operation was successful.

delete()

delete: (key, options?) => boolean | Promise<boolean>;

Deletes the value associated with a key from the store.

Parameters

ParameterTypeDescription
keystringThe key associated with the value to delete.
options?FlashcoreOptions-

Returns

boolean | Promise<boolean>

  • Resolves to a boolean indicating whether the operation was successful.

get()

get: <V>(key, options?) => V | Promise<V>;

Gets the value associated with a key.

Type Parameters

Type ParameterDescription
VThe type of the value.

Parameters

ParameterTypeDescription
keystringThe key associated with the value.
options?FlashcoreOptions & object-

Returns

V | Promise<V>

  • May return a promise you can await or the value directly.

has()

has: (key, options?) => boolean | Promise<boolean>;

Checks if a key exists in the store.

Parameters

ParameterTypeDescription
keystringThe key to check.
options?FlashcoreOptionsOptions for the operation.

Returns

boolean | Promise<boolean>

  • A boolean indicating whether the key exists.

off()

off: (key, callback?, options?) => void;

Unregisters a callback from a key, so it will no longer be executed when the key's value changes.

Parameters

ParameterTypeDescription
keystringThe key to stop watching.
callback?WatcherCallback<unknown>The callback function to remove from the key's watch list. If no callback is provided, all callbacks associated with the key are removed.
options?FlashcoreOptions-

Returns

void

on()

on: (key, callback, options?) => void;

Registers a callback to be executed when a specific key's value changes in the store.

Parameters

ParameterTypeDescription
keystringThe key to watch for changes.
callbackWatcherCallback<unknown>The callback function to execute when the key's value changes. The callback receives the new and old values as arguments.
options?FlashcoreOptions-

Returns

void

set()

set: <V>(key, value, options?) => boolean | Promise<boolean>;

Sets a key-value pair in the store.

Type Parameters

Type ParameterDescription
VThe type of the value.

Parameters

ParameterTypeDescription
keystringThe key to associate with the value.
valueVThe value to set.
options?FlashcoreOptions-

Returns

boolean | Promise<boolean>

  • Resolves to a boolean indicating whether the operation was successful.