{"id":16308,"library":"brackets-memory-db","title":"Brackets Memory Database","description":"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.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/Drarig29/brackets-storage","tags":["javascript","types","model","brackets","tournament","manager","storage","memory","typescript"],"install":[{"cmd":"npm install brackets-memory-db","lang":"bash","label":"npm"},{"cmd":"yarn add brackets-memory-db","lang":"bash","label":"yarn"},{"cmd":"pnpm add brackets-memory-db","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package provides an in-memory `CrudInterface` implementation that must be passed to an instance of `BracketsManager`.","package":"brackets-manager","optional":false}],"imports":[{"note":"The primary export is a named class, `MemoryStorage`. While CommonJS `require` might technically work in some setups, ESM import syntax is recommended and correctly typed.","wrong":"const { MemoryStorage } = require('brackets-memory-db');","symbol":"MemoryStorage","correct":"import { MemoryStorage } from 'brackets-memory-db';"},{"note":"The `CrudInterface` itself is typically imported from `brackets-manager` for type declarations, not `brackets-memory-db`, as this package implements that interface.","wrong":"import { MemoryStorage, CrudInterface } from 'brackets-memory-db';","symbol":"MemoryStorage","correct":"import type { CrudInterface } from 'brackets-manager';"}],"quickstart":{"code":"import { BracketsManager } from 'brackets-manager';\nimport { MemoryStorage } from 'brackets-memory-db';\n\nasync function setupTournament() {\n  // 1. Instantiate the in-memory storage.\n  const storage = new MemoryStorage();\n\n  // 2. Pass the storage instance to the BracketsManager.\n  const manager = new BracketsManager(storage);\n\n  // 3. Create a new tournament.\n  await manager.create.tournament({\n    name: 'My Awesome Tournament',\n    slug: 'my-awesome-tournament',\n    description: 'A test tournament running in memory.',\n    sport: 'esports',\n  });\n\n  // 4. Create a stage for the tournament.\n  const tournamentId = (await manager.get.tournament('my-awesome-tournament'))?.id;\n  if (tournamentId === undefined) {\n    throw new Error('Tournament not found');\n  }\n\n  await manager.create.stage({\n    tournamentId,\n    name: 'Single Elimination Stage',\n    type: 'single_elimination',\n    seeding: ['Team A', 'Team B', 'Team C', 'Team D'],\n    settings: { size: 4 },\n  });\n\n  console.log('Tournament and stage created in memory!');\n  const matches = await manager.get.matches(tournamentId);\n  console.log('Current matches:', matches);\n}\n\nsetupTournament().catch(console.error);\n","lang":"typescript","description":"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."},"warnings":[{"fix":"For persistent storage, consider other `brackets-manager` implementations like `brackets-json-db`, `brackets-prisma-db`, or `brackets-sql-db`, or implement custom serialization/deserialization logic to save/load the in-memory state.","message":"Data stored in `brackets-memory-db` is volatile and will be lost when the application process terminates or the browser page is refreshed. It does not provide any inherent persistence mechanism.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Evaluate your persistence requirements. For server-side applications, choose a database-backed `CrudInterface` implementation. For browser apps, ensure any critical data is saved to `localStorage`, `indexedDB`, or a remote API.","message":"This package is suitable for browser-based applications or backend processes where data can be re-generated or is explicitly saved externally. It is not designed as a primary, durable database for production systems requiring data integrity across restarts.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review the GitHub repository's issue tracker and commit history for current activity. Be mindful of potential compatibility issues with newer versions of `brackets-manager` if this package is not updated concurrently.","message":"The package's last publish was over two years ago. While this can indicate stability, it also means infrequent updates, which might lead to slower bug fixes or a delay in adopting new features or TypeScript versions from its `brackets-manager` peer dependency.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure you are using ESM `import { MemoryStorage } from 'brackets-memory-db';`. If in Node.js, ensure your `package.json` has `\"type\": \"module\"` or you are using `.mjs` files. For TypeScript, verify `tsconfig.json` settings (`moduleResolution`, `module`).","cause":"This error often occurs when mixing CommonJS `require()` with an ESM-first package, using an incorrect import path, or when TypeScript cannot find the type definitions.","error":"Error: Cannot find module 'brackets-memory-db' or its corresponding type declarations."},{"fix":"Double-check that `const storage = new MemoryStorage();` successfully creates an instance and that `new BracketsManager(storage);` is correctly called, passing the `storage` object.","cause":"This error typically indicates that the `BracketsManager` instance was not properly initialized with a valid storage implementation, or the storage instance itself is `undefined`.","error":"TypeError: Cannot read properties of undefined (reading 'create')"}],"ecosystem":"npm"}