{"library":"najm-database","title":"Najm Database Plugin","description":"Community-maintained database plugin for the Najm API framework (v1.1.8). Provides decorator-based transaction management, automatic rollback, Drizzle ORM integration, and Zod schema validation. Requires najm-core, reflect-metadata, drizzle-orm >=0.36.0, and zod. Updated monthly. Differentiator: declarative @Transactional decorator with automatic commit/rollback tied to request lifecycle, reducing boilerplate for Najm-based APIs.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install najm-database"],"cli":null},"imports":["import { DatabasePlugin } from 'najm-database'","import { Transactional } from 'najm-database'","import type { DatabaseConfig } from 'najm-database'","import NajmDatabase from 'najm-database'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { DatabasePlugin, Transactional } from 'najm-database';\nimport { drizzle } from 'drizzle-orm/node-postgres';\nimport { Pool } from 'pg';\n\nconst pool = new Pool({ connectionString: process.env.DB_URL ?? '' });\nconst db = drizzle(pool);\n\n// Register plugin with Najm framework\nimport { Najm } from 'najm-core';\nconst app = new Najm();\napp.use(DatabasePlugin, { db });\n\n// Use @Transactional decorator in a service\nclass UserService {\n  @Transactional()\n  async createUser(data: { name: string }) {\n    // This method runs inside a database transaction\n    // Automatically commits on success, rolls back on error\n    return await db.insert(users).values(data).returning();\n  }\n}","lang":"typescript","description":"Shows how to initialize the DatabasePlugin with a Drizzle ORM instance and use the @Transactional decorator on a method to wrap it in a database transaction.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}