Databases

A database in NotDatabase is the root container for all your data. Every collection, document, and schema you define lives inside a single database.

You can create one database and define multiple collections inside it, like this:

 import { createClient } from "notdb";
      
const db = createClient({
  apiKey: "your_api_key",
  schema: {
    users: {
      properties: {
        name: { type: "string", required: true },
        email: { type: "string", required: true, unique: true },
      },
    },
    companies: {
      properties: {
        name: { type: "string", required: true },
        ceo: { type: "string" },
      },
    },
  },
});

Here, users and companies are both collections inside the same database.

🔒 Scoped by API Key

Your database is identified by your API key. That means:

  • Everything is isolated to your key
  • Multiple apps can use their own keys