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

@n0n3br/browser-db

v1.0.0

Published

A lightweight and efficient browser database library using IndexedDB

Downloads

5

Readme

Browser-DB

A lightweight, TypeScript-based IndexedDB wrapper that provides SQL-like functionality for browser applications.

Features

  • Simple API for database and table management
  • CRUD operations with TypeScript generics for type safety
  • SQL-like query capabilities with conditions and operators ($eq, $gt, $gte, $lt, $lte, $ne)
  • Advanced table joins (inner, left, right, full)
  • Pagination and sorting support
  • Indexing for optimized queries
  • Promise-based interface for modern async/await usage
  • Full TypeScript support with type definitions
  • Batch operations support
  • Transaction management

Installation

npm install @n0n3br/browser-db

Usage

Initialize and Open Database

import { BrowserDB } from '@n0n3br/browser-db';

// Create a new database instance
const db = new BrowserDB('myDatabase', 1);

// Open the database connection
await db.open();

Create a Table

// Define your data interface
interface User {
  id?: number;
  name: string;
  email: string;
  age: number;
}

// Create a table with schema
await db.createTable({
  name: 'users',
  keyPath: 'id',
  autoIncrement: true,
  indexes: [
    { name: 'email', keyPath: 'email', options: { unique: true } },
    { name: 'name', keyPath: 'name' }
  ]
});

Basic CRUD Operations

// Insert a record
const userId = await db.insert('users', {
  name: 'John Doe',
  email: '[email protected]',
  age: 30
});

// Get a record by key
const user = await db.get('users', userId);

// Update a record
await db.update('users', {
  id: userId,
  name: 'John Smith',
  email: '[email protected]',
  age: 31
});

// Delete a record
await db.delete('users', userId);

Batch Operations

// Batch insert multiple records
const userIds = await db.insert('users', [
  { name: 'John Doe', email: '[email protected]', age: 30 },
  { name: 'Jane Smith', email: '[email protected]', age: 25 }
]);

// Batch update multiple records
await db.update('users', [
  { id: userIds[0], name: 'John Smith', email: '[email protected]', age: 31 },
  { id: userIds[1], name: 'Jane Doe', email: '[email protected]', age: 26 }
]);

// Batch delete multiple records
await db.delete('users', userIds);

// Update multiple records using a condition
await db.update('users', 
  { age: { $lt: 30 } }, // condition
  { active: true }     // updates to apply
);

// Delete multiple records using a condition
await db.delete('users', { age: { $gt: 50 } });

Query Operations

// Find records with conditions
const users = await db.find('users', {
  age: { $gt: 25, $lt: 35 },
  name: 'John Smith'
});

// Get all records with pagination and sorting
const options = {
  limit: 10,
  offset: 0,
  direction: 'next' // or 'prev' for reverse order
};
const allUsers = await db.getAll('users', options);

// Count records
const totalUsers = await db.count('users');

Join Operations

interface Order {
  id?: number;
  userId: number;
  total: number;
}

// Create orders table
await db.createTable({
  name: 'orders',
  keyPath: 'id',
  autoIncrement: true,
  indexes: [{ name: 'userId', keyPath: 'userId' }]
});

// Perform an inner join
const userOrders = await db.join(
  'users',
  'orders',
  { leftKey: 'id', rightKey: 'userId' },
  { type: 'inner' } // 'inner', 'left', 'right', or 'full'
);

Table and Database Management

// Clear all records from a table
await db.clear('users');

// Drop a table
await db.dropTable('users');

// Drop the entire database
await db.dropDatabase();

// Close the database connection
db.close();

API Reference

BrowserDB Class

Constructor

  • new BrowserDB(dbName: string = 'browserDB', version: number = 1)

Methods

  • open(): Promise<BrowserDB> - Open database connection
  • close(): void - Close database connection
  • dropDatabase(): Promise<void> - Delete the database

Table Operations

  • createTable(schema: TableSchema): Promise<void> - Create a new table
  • dropTable(tableName: string): Promise<void> - Drop a table
  • clear(tableName: string): Promise<void> - Clear all records in a table

CRUD Operations

  • insert<T>(tableName: string, data: T | T[]): Promise<IDBValidKey | IDBValidKey[]> - Insert one or more records
  • update<T>(tableName: string, dataOrCondition: T | T[] | QueryCondition<T>, updates?: Partial<T>): Promise<void> - Update records
  • delete(tableName: string, keysOrCondition: IDBValidKey | IDBValidKey[] | QueryCondition<T>): Promise<void> - Delete records
  • get<T>(tableName: string, key: IDBValidKey): Promise<T | null> - Get a record by key

Query Operations

  • getAll<T>(tableName: string, options?: QueryOptions): Promise<T[]> - Get all records
  • find<T>(tableName: string, condition: QueryCondition<T>, options?: QueryOptions): Promise<T[]> - Find records
  • count(tableName: string): Promise<number> - Count records
  • join<T, U, R>(leftTableName: string, rightTableName: string, condition: JoinCondition<T, U>, options?: JoinOptions): Promise<R[]> - Join tables

License

ISC