Registry / database / nc-db-new

nc-db-new

JSON →
library1.6.7jsnpmunverified

The `nc-db-new` package provides the foundational database models for the NextUp Comedy website and its associated services. Designed as an internal library, it centralizes the schema definitions, relationships, and often the data access logic for core entities such as Users, Shows, Venues, and Bookings specific to the comedy platform. Currently at version 1.6.7, this package ensures consistent data structures across various backend applications and microservices within the NextUp Comedy ecosystem. Its primary function is to abstract database interactions, enabling developers to work with TypeScript classes or interfaces that map directly to database tables. While its release cadence is tied to internal development cycles, it aims for stability in its minor and patch versions, with breaking changes typically confined to major version bumps. Key differentiators are its highly specialized domain model and its deep integration into the NextUp Comedy tech stack, providing a single source of truth for database schema.

npm install nc-db-new
INSTALL
IMPORT
SIG · NC-DB-NEW
N
nc-db-new
databasejavascriptv1.6.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

User
import { User } from 'nc-db-new';
const { User } = require('nc-db-new');
Prefer ES module imports; CommonJS `require` might not work correctly or lead to type issues, especially in newer Node.js environments.
Show
import { Show } from 'nc-db-new';
Individual models are typically exported as named exports. Avoid default imports unless explicitly specified by the library.
UserAttributes
import type { UserAttributes } from 'nc-db-new';
import { UserAttributes } from 'nc-db-new';
When importing only types, use `import type` to ensure they are stripped from the JavaScript output, preventing potential runtime errors or unnecessary bundle size increase.

Demonstrates importing `User` and `Show` models, simulating database operations like creating and finding entities.

import { User, Show, db } from 'nc-db-new'; async function main() { // Assume 'db' is an initialized ORM instance or connection pool // For demonstration, we'll mock 'db.sync' and 'User.create' console.log('Synchronizing database models...'); // await db.sync(); // In a real app, this might create/update tables console.log('Database models synchronized.'); try { const newUser = await User.create({ username: 'comedyfan', email: `fan_${Date.now()}@example.com`, passwordHash: 'hashedpassword123', is_admin: false }); console.log('Created new user:', newUser.toJSON()); const allUsers = await User.findAll(); console.log('Total users:', allUsers.length); const firstShow = await Show.findOne({ where: { title: 'The Laughter Gala' } }); if (firstShow) { console.log('Found show:', firstShow.toJSON()); } else { console.log('No show found with title "The Laughter Gala", creating one...'); const createdShow = await Show.create({ title: 'The Laughter Gala', date: new Date('2026-07-20T19:00:00Z'), venueId: 'venue-abc-123' // Assume a venue ID exists or is created elsewhere }); console.log('Created new show:', createdShow.toJSON()); } } catch (error) { console.error('Database operation failed:', error); } } // Simulate an initialized 'db' object and model methods for the quickstart const mockDb = { sync: async () => Promise.resolve(), }; const mockUser = { create: async (data: any) => ({ ...data, id: Math.random().toString(36).substring(7), toJSON: () => ({ ...data, id: 'mock-user-id' }) }), findAll: async () => ([{ username: 'existing', email: 'existing@example.com', toJSON: () => ({ username: 'existing', email: 'existing@example.com' }) }]), toJSON: () => ({}) // For compatibility }; const mockShow = { findOne: async (options: any) => options.where.title === 'The Laughter Gala' ? null : ({ title: 'Existing Comedy Night', date: new Date(), toJSON: () => ({ title: 'Existing Comedy Night' }) }), create: async (data: any) => ({ ...data, id: Math.random().toString(36).substring(7), toJSON: () => ({ ...data, id: 'mock-show-id' }) }) }; // Overwrite for quickstart execution // @ts-ignore (globalThis as any).db = mockDb; // @ts-ignore (globalThis as any).User = mockUser; // @ts-ignore (globalThis as any).Show = mockShow; main();
Debug
Known issues
gotchaSchema drift can occur if database migrations are not run consistently with model changes. Always ensure your database schema matches the model definitions in the `nc-db-new` package.
fix
Implement robust migration strategies using tools like Flyway, Liquibase, or ORM-specific migration utilities. Validate schema synchronization in CI/CD pipelines.
affects: >=1.0.0
breakingMajor version updates (e.g., from v1 to v2) are likely to introduce breaking changes in model definitions, field types, or relationships. Always consult the changelog before upgrading.
fix
Review the package's changelog thoroughly for breaking changes. Update your application code, database migrations, and data transformation scripts as necessary to align with the new version.
affects: >=1.0.0
gotchaThe models typically rely on an underlying ORM or database connection instance (e.g., `db`). Incorrect initialization or configuration of this instance will lead to runtime errors when performing database operations.
fix
Ensure the database connection and ORM (if applicable) are correctly initialized and passed to the models, or globally accessible, before attempting any database interactions. Verify connection string, credentials, and pool settings.
affects: >=1.0.0
gotchaPerformance issues like N+1 queries can arise from inefficient data fetching patterns, especially when dealing with related entities. Eager loading or careful query construction is often required.
fix
Utilize ORM features like `include` or `join` to eager load related data. Analyze query performance using database monitoring tools and refactor data access patterns to reduce redundant queries.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'create')
The `db` object or specific model (e.g., `User`) was not properly initialized or imported before use, or the underlying ORM instance is not connected.
fix
Ensure `db` and models are correctly imported and initialized. Verify that the database connection is established and the ORM instance is available where models are being used.
Property 'someField' does not exist on type 'User'.
Attempting to access a field that is not defined in the `User` model's TypeScript interface or class, or a field that was not explicitly selected in a query.
fix
Update your model definitions in `nc-db-new` if `someField` is new. If it's an existing field, ensure your query explicitly selects it, or that the return type of your query includes it.
Error: SQLITE_CONSTRAINT: NOT NULL constraint failed: users.email
Attempted to insert or update a database record without providing a value for a column that is marked as `NOT NULL` in the database schema.
fix
Review your model's create/update data to ensure all required fields (especially `NOT NULL` columns) are provided with valid values.
Upgrade
Version history
1.6.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
nc-db-new — npm install nc-db-new · libregistry