Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/grammy/mod.ts>StorageAdapter

The Telegram Bot Framework.
Very Popular
Latest
interface StorageAdapter
import { type StorageAdapter } from "https://deno.land/x/grammy@v1.30.1/mod.ts";

A storage adapter is an abstraction that provides read, write, and delete access to a storage solution of any kind. Storage adapters are used to keep session middleware independent of your database provider, and they allow you to pass your own storage solution.

Properties

read: (key: string) => MaybePromise<T | undefined>

Reads a value for the given key from the storage. May return the value or undefined, or a promise of either.

write: (key: string, value: T) => MaybePromise<void>

Writes a value for the given key to the storage.

delete: (key: string) => MaybePromise<void>

Deletes a value for the given key from the storage.

optional
has: (key: string) => MaybePromise<boolean>

Checks whether a key exists in the storage.

optional
readAllKeys: () => Iterable<string> | AsyncIterable<string>

Lists all keys.

optional
readAllValues: () => Iterable<T> | AsyncIterable<T>

Lists all values.

optional
readAllEntries: () => Iterable<[string, T]> | AsyncIterable<[string, T]>

Lists all keys with their values.