🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@ariestools/indexed-db

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ariestools/indexed-db

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

latest
Source
npmnpm
Version
8.0.3
Version published
Maintainers
1
Created
Source

logo

@ariestools/indexed-db

npm license

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

Install

Using npm:

npm install {{name}}

Using yarn:

yarn add {{name}}

Using pnpm:

pnpm add {{name}}

Using bun:

bun add {{name}}

License

See the LICENSE file for license rights and limitations (LGPL-3.0-only).

Reference

packages

indexed-db

### .temp-typedoc

  ### classes

    ### <a id="IndexedDbKeyValueStore"></a>IndexedDbKeyValueStore

@ariestools/indexed-db

An IndexedDB key/value store.

Type Parameters

T

T extends DBSchema

S

S extends StoreNames<T>

Implements

  • KeyValueStore<StoreValue<T, S>, StoreKey<T, S>>

Constructors

Constructor

new IndexedDbKeyValueStore<T, S>(dbName, storeName): IndexedDbKeyValueStore<T, S>;

Parameters

dbName

string

storeName

S

Returns

IndexedDbKeyValueStore<T, S>

Properties

dbName

readonly dbName: string;

The name of the IndexedDB database.

storeName

readonly storeName: S;

The name of the object store within the database.

Methods

clear()?

optional clear(): Promise<void>;

Removes all entries from the store.

Returns

Promise<void>

Implementation of

KeyValueStore.clear

delete()

delete(key): Promise<void>;

Deletes the entry with the given key.

Parameters

key

StoreKey<T, S>

The key of the entry to delete

Returns

Promise<void>

Implementation of

KeyValueStore.delete

get()

get(key): Promise<StoreValue<T, S> | undefined>;

Retrieves the value associated with the given key.

Parameters

key

StoreKey<T, S>

The key to look up

Returns

Promise<StoreValue<T, S> | undefined>

The value, or undefined if not found

Implementation of

KeyValueStore.get

keys()?

optional keys(): Promise<StoreKey<T, S>[]>;

Returns all keys in the store.

Returns

Promise<StoreKey<T, S>[]>

Implementation of

KeyValueStore.keys

set()

set(key, value): Promise<void>;

Sets a value for the given key, creating or updating the entry.

Parameters

key

StoreKey<T, S>

The key to set

value

StoreValue<T, S>

The value to store

Returns

Promise<void>

Implementation of

KeyValueStore.set

withDb()

withDb<R>(callback): Promise<R>;

Opens the underlying IndexedDB database and passes it to the callback.

Type Parameters

R

R = StoreValue<T, S>

Parameters

callback

(db) => R | Promise<R>

Function to execute with the database

Returns

Promise<R>

The result of the callback

  ### functions

    ### <a id="buildStandardIndexName"></a>buildStandardIndexName

@ariestools/indexed-db

function buildStandardIndexName(index): string;

Given an index description, this will build the index name in standard form

Parameters

index

IndexDescription

The index description

Returns

string

The index name in standard form

    ### <a id="checkDbNeedsUpgrade"></a>checkDbNeedsUpgrade

@ariestools/indexed-db

function checkDbNeedsUpgrade(
   dbName, 
   stores, 
logger?): Promise<number>;

Checks whether any store in the database needs an upgrade and returns the appropriate version number.

Parameters

dbName

string

The name of the database to check

stores

Record<string, [IndexDescription]#../interfaces/IndexDescription>

Map of store names to their expected index descriptions

logger?

Logger

Optional logger for diagnostics

Returns

Promise<number>

The version to open (current version + 1 if upgrade needed, otherwise current version)

    ### <a id="createStoreDuringUpgrade"></a>createStoreDuringUpgrade

@ariestools/indexed-db

function createStoreDuringUpgrade<DBTypes>(
   db, 
   storeName, 
   indexes, 
   logger?): void;

Creates an object store with the specified indexes during a version upgrade transaction.

Type Parameters

DBTypes

DBTypes extends unknown = unknown

Parameters

db

IDBPDatabase<DBTypes>

The IndexedDB database instance (during upgrade)

storeName

StoreNames<DBTypes>

The name of the store to create

indexes

[IndexDescription]#../interfaces/IndexDescription

The index descriptions to create on the store

logger?

Logger

Optional logger for diagnostics

Returns

void

    ### <a id="getExistingIndexes"></a>getExistingIndexes

@ariestools/indexed-db

function getExistingIndexes<T>(
   db, 
   storeName, 
logger?): Promise<IndexDescription[] | null>;

Retrieves the existing index descriptions for a store. Accepts either a database instance or a database name.

Type Parameters

T

T extends object = object

Parameters

db

| string | IDBPDatabase<ObjectStore<T>>

The IndexedDB database instance or database name

storeName

StoreNames<ObjectStore<T>>

The name of the store to inspect

logger?

Logger

Optional logger for diagnostics

Returns

Promise<[IndexDescription]#../interfaces/IndexDescription | null>

An array of index descriptions, or null if the store does not exist

    ### <a id="withDb"></a>withDb

@ariestools/indexed-db

function withDb<DBTypes, R>(
   dbName, 
   callback, 
   expectedIndexes?, 
   logger?, 
lock?): Promise<R>;

Opens an IndexedDB database, automatically upgrading if needed, and passes it to the callback. Uses a mutex to serialize access to the same database by default.

Type Parameters

DBTypes

DBTypes extends unknown = unknown

R

R = object

Parameters

dbName

string

The name of the database to open

callback

(db) => R | Promise<R>

Function to execute with the opened database

expectedIndexes?

Record<string, [IndexDescription]#../interfaces/IndexDescription>

Optional map of store names to their expected indexes (triggers upgrade check)

logger?

Logger

Optional logger for diagnostics

lock?

boolean = true

Whether to use a mutex to serialize access (defaults to true)

Returns

Promise<R>

The result of the callback

    ### <a id="withDbByVersion"></a>withDbByVersion

@ariestools/indexed-db

function withDbByVersion<DBTypes, R>(
   dbName, 
   callback, 
   version?, 
   expectedIndexes?, 
   logger?, 
lock?): Promise<R>;

Opens an IndexedDB database at a specific version, handling upgrade events, and passes it to the callback. The database is automatically closed after the callback completes.

Type Parameters

DBTypes

DBTypes extends unknown = unknown

R

R = object

Parameters

dbName

string

The name of the database to open

callback

(db) => R | Promise<R>

Function to execute with the opened database

version?

number

Optional specific version to open (undefined for latest)

expectedIndexes?

Record<string, [IndexDescription]#../interfaces/IndexDescription>

Optional map of store names to indexes to create during upgrade

logger?

Logger

Optional logger for diagnostics

lock?

boolean = true

Whether to use a mutex to serialize access (defaults to true)

Returns

Promise<R>

The result of the callback

    ### <a id="withReadOnlyStore"></a>withReadOnlyStore

@ariestools/indexed-db

function withReadOnlyStore<T, R>(
   db, 
   storeName, 
   callback, 
logger?): Promise<R>;

Opens a read-only transaction on the specified store and passes it to the callback.

Type Parameters

T

T extends object = object

R

R = T

Parameters

db

IDBPDatabase<ObjectStore<T>>

The IndexedDB database instance

storeName

StoreNames<ObjectStore<T>>

The name of the object store to open

callback

(store) => R | Promise<R>

Function to execute with the read-only store

logger?

Logger

Optional logger for diagnostics

Returns

Promise<R>

The result of the callback

    ### <a id="withReadWriteStore"></a>withReadWriteStore

@ariestools/indexed-db

function withReadWriteStore<T, R>(
   db, 
   storeName, 
   callback, 
logger?): Promise<R>;

Opens a read-write transaction on the specified store and passes it to the callback.

Type Parameters

T

T extends object = object

R

R = T

Parameters

db

IDBPDatabase<ObjectStore<T>>

The IndexedDB database instance

storeName

StoreNames<ObjectStore<T>>

The name of the object store to open

callback

(store) => R | Promise<R>

Function to execute with the read-write store

logger?

Logger

Optional logger for diagnostics

Returns

Promise<R>

The result of the callback

    ### <a id="withStore"></a>withStore

@ariestools/indexed-db

function withStore<T, R, M>(
   db, 
   storeName, 
   callback, 
   mode, 
logger?): Promise<R>;

Opens a transaction on the specified store with the given mode and passes the store to the callback. If the store does not exist, the callback receives null.

Type Parameters

T

T extends object = object

R

R = T

M

M extends "readonly" | "readwrite" = "readonly"

Parameters

db

IDBPDatabase<ObjectStore<T>>

The IndexedDB database instance

storeName

StoreNames<ObjectStore<T>>

The name of the object store to open

callback

(store) => R | Promise<R>

Function to execute with the store (or null if it doesn't exist)

mode

M

The transaction mode ('readonly' or 'readwrite')

logger?

Logger

Optional logger for diagnostics

Returns

Promise<R>

The result of the callback

  ### interfaces

    ### <a id="IndexDescription"></a>IndexDescription

@ariestools/indexed-db

Description of index(es) to be created on a store

Properties

key

key: Record<string, IndexDirection>;

The key(s) to index

multiEntry?

optional multiEntry?: boolean;

Is the indexed value an array

unique?

optional unique?: boolean;

If true, the index must enforce uniqueness on the key

  ### type-aliases

    ### <a id="IndexDirection"></a>IndexDirection

@ariestools/indexed-db

type IndexDirection = -1 | 1;

The index direction (1 for ascending, -1 for descending)

    ### <a id="ObjectStore"></a>ObjectStore

@ariestools/indexed-db

type ObjectStore<T> = Record<string, T>;

Generic IndexedDB schema type that maps store names to their value types.

Type Parameters

T

T extends EmptyObject = EmptyObject

  ### variables

    ### <a id="IndexSeparator"></a>IndexSeparator

@ariestools/indexed-db

const IndexSeparator: "-" = '-';

Separator used between key names when building standard index names.

Credits

Made with 🔥 and ❄️ by XY Labs

Keywords

ariestools

FAQs

Package last updated on 07 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts