Your clientside data,

blazingly fast

blinkDB is an in-memory database optimized for offline first web apps. With full support for indexes, queries, and popular frontend frameworks.
// All users called Alice or Charlie
// with an age greater than 24
const items = await many(userTable, {
  where: {
    name: { in: ['Alice', 'Charlie'] },
    age: { gt: 24 }
  },
});
blinkDB ⚡ (0.031ms)
JS Map() (3.053ms)
lokijs (4.803ms)
above query for 100.000 items

Use the right tool for the job.

blinkDB makes it easy to query, persist, and sync large amounts of entities on the frontend - perfect for web apps designed to run offline.

Full type safety.

Fully typesafe entities. Automatic property inference in queries. BlinkDB is 100% written in Typescript, and automatically prevents issues with incorrect or outdated types.

main.ts
import { createDB, createTable, insertMany, uuid } from "blinkdb";
import { User } from "./User.ts";

// Set up the table
const db = createDB();
const userTable = createTable<User>(db, "users")();

// Insert the users!
await insertMany(userTable, [
  { id: uuid(), name: "Alice", posts: [{ content: "Hello World! :)" }] },
  { id: uuid(), name: "Bob", age: 24 },
  { id: uuid(), age: 25 } // ERROR: Property 'name' is missing
]);
User.ts
export interface User {
  id: number;
  name: string;
  age?: number;
  posts?: { content: string }[];
};

Powerful queries.

Filter, sort, and paginate directly in BlinkDB like in any other database. Automatically take advantage of indexes. Use batch & in-place update/remove operations.

filter.ts
// All users called Alice or Charlie
// with an age greater than 24
const items = await many(userTable, {
  where: {
    name: { in: ['Alice', 'Charlie'] },
    age: { gt: 24 }
  },
});
sort.ts
// First user in the alphabet
// who's younger than 30yrs
const items = await first(userTable, {
  where: {
    age: { lt: 30 }
  },
  sort: {
    key: "name",
    order: "asc"
  }
});
limit.ts
// Just user 10-20 please :)
const items = await many(userTable, {
  limit: {
    take: 10,
    skip: 10
  }
});

Completely realtime.

React to changes in your database as soon as they occur. Keep your UI always up-to-date with the current state.

watch.ts
// React to changes on the userTable
await watch(userTable, { where: { name: "Alice" } }, (aliceUsers) => {
  console.log("Users named Alice: ", aliceUsers.length);
});
button.tsx
export const AddEntityButton = () => {
  const onButtonClick = () => {
    await insert(userTable, { name: "Alice", age: 25 });
  };

  return (
    <button onClick={onButtonClick}>
      Click Me
    </button>
  );
};

Console log

blinkDB © 2023