npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dalgo/indexeddb

v0.4.1

Published

IndexedDB adapter for DALgo TypeScript

Readme

@dalgo/indexeddb

Native browser IndexedDB adapter for @dalgo/core.

This adapter provides local, same-origin browser persistence. It complements @dalgo/firestore; it does not synchronize IndexedDB with Firestore or an OpenVaultDB server by itself.

Install

pnpm add @dalgo/core @dalgo/indexeddb

The required peer range is @dalgo/core >=0.8.0 <0.9.0, the first core line with the TugQL names.

Use

import { collection } from "@dalgo/core";
import { IndexedDbDatabase } from "@dalgo/indexeddb";

interface Todo {
  title: string;
  done: boolean;
  rank: number;
}

const db = new IndexedDbDatabase({ name: "my-app" });
const todos = collection<Todo>("todos");

await db.runReadwriteTransaction(async (transaction) => {
  await transaction.set(todos.key("first"), {
    title: "Try DALgo",
    done: false,
    rank: 1,
  });
});

const page = await db.query(
  todos.query()
    .where("done", "==", false)
    .orderBy("rank")
    .limit(20)
    .build(),
);

Call await db.close() before deleting or upgrading a database from another tab.

Storage model

By default, the adapter owns one object store named __dalgo_records. Records retain their complete hierarchical DALgo keys and are indexed by collection path and collection name. This fixed schema means new DALgo collections do not require IndexedDB version upgrades.

For a database whose collections are known in advance, pass collections to expose each one as its own IndexedDB object store:

const db = new IndexedDbDatabase({
  name: "chinook",
  collections: [
    { name: "main.Customer", storeName: "Customer" },
    { name: "main.Invoice", storeName: "Invoice" },
    { name: "main.Track", storeName: "Track" },
  ],
});

Strings can also be used when the DALgo collection name and IndexedDB object store name are identical. Only the listed collections can be read or written. Additions to that list require an IndexedDB version upgrade (or a new database name). Choose the layout when creating a database; changing an existing shared-store database to named stores does not migrate its records.

Collection and collection-group selection uses IndexedDB cursors. DALgo filters, ordering, cursors, offsets, and limits are evaluated as records arrive. A query with limit retains at most offset + limit candidate records in memory; it still scans the selected collection when filtering or ordering cannot use a native index. An unbounded query returns all matching records and can use proportionally more memory.

When an imported source stores exact decimals or wide integers as strings, opt the relevant fields into numeric comparison. Ordinary text, including postal codes such as "001", keeps lexical ordering:

import { withIndexedDbQueryHints } from "@dalgo/indexeddb";

const query = withIndexedDbQueryHints(
  invoices.query().where("total", ">", "9007199254740992").orderBy("total").limit(20).build(),
  { numericFields: ["total"], signal: controller.signal },
);
const page = await db.query(query);

Hints apply to this query only; fields marked numeric must contain decimal strings or safe integer numbers. Decimal comparison is exact within the adapter's 1,000-digit scale bound. Cancellation rejects the query without returning a partial page.

Recursive TugQL

Run recursive TugQL through executeRecursiveTugQLQuery from @dalgo/core. The core sends this adapter ordinary, bounded leaf queries; calling IndexedDbDatabase.query() with a recursive AST is rejected before the database opens. The leaf path scans IndexedDB cursors. A bounded leaf retains only its requested page, although a filter or sort may still require visiting every record in the selected collection.

runReadwriteTransaction uses a real IndexedDB read-write transaction. Its callback should await only DALgo operations; awaiting timers, network calls, or unrelated work can allow the browser to make the native transaction inactive.

Runtime and testing

The package uses the browser's global indexedDB by default. Tests and non-browser runtimes can inject an IDBFactory:

const db = new IndexedDbDatabase({ name: "test", factory });

Development

pnpm install
npm run check

License

MIT