Creating Tables

Once you’ve installed blinkDB, you can create your own database.

import { createDB } from "blinkdb";

const db = createDB();

Similar to a relational database, entities are stored in Tables in blinkDB. You can create them with createTable<Interface>(db, <name>)() (be sure to call createTable twice, like in the example below). Each table contains entities of a certain type.

Every table requires a TS interface/type that specifies what entities in that table look like. You can use almost all typescript types in your entity definition (see the list of valid property types here).

import { createDB, createTable } from "blinkdb";

interface User {
  id: string;
  name: string;
  age?: number;
}

const db = createDB();
const table = createTable<User>(db, "users")();

🥳🎉 Congratulations - it’s that simple! You can now create, query, update, and delete items.

blinkDB © 2023