Brackets Memory Database

1.0.5 · active · verified Wed Apr 22

brackets-memory-db is an in-memory implementation of the `CrudInterface` for the `brackets-manager.js` ecosystem, designed to store tournament bracket data directly in application memory. The current stable version is 1.0.5, last published over two years ago, indicating a stable but infrequent release cadence. It provides a simple, type-safe storage solution that is particularly well-suited for client-side applications running in the browser, where data persistence is managed by the client's session or explicitly handled by the application logic. It's also an excellent choice for testing, prototyping, or scenarios requiring temporary, ephemeral storage without the overhead of a persistent database. Its key differentiators are its tight integration with `brackets-manager.js` and its straightforward, zero-configuration setup for in-memory operations.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up `brackets-manager` with `brackets-memory-db` as its storage backend, creating a simple tournament and stage entirely in memory. It highlights the basic instantiation and interaction pattern.

import { BracketsManager } from 'brackets-manager';
import { MemoryStorage } from 'brackets-memory-db';

async function setupTournament() {
  // 1. Instantiate the in-memory storage.
  const storage = new MemoryStorage();

  // 2. Pass the storage instance to the BracketsManager.
  const manager = new BracketsManager(storage);

  // 3. Create a new tournament.
  await manager.create.tournament({
    name: 'My Awesome Tournament',
    slug: 'my-awesome-tournament',
    description: 'A test tournament running in memory.',
    sport: 'esports',
  });

  // 4. Create a stage for the tournament.
  const tournamentId = (await manager.get.tournament('my-awesome-tournament'))?.id;
  if (tournamentId === undefined) {
    throw new Error('Tournament not found');
  }

  await manager.create.stage({
    tournamentId,
    name: 'Single Elimination Stage',
    type: 'single_elimination',
    seeding: ['Team A', 'Team B', 'Team C', 'Team D'],
    settings: { size: 4 },
  });

  console.log('Tournament and stage created in memory!');
  const matches = await manager.get.matches(tournamentId);
  console.log('Current matches:', matches);
}

setupTournament().catch(console.error);

view raw JSON →