npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cerebro-modeler

v1.3.0

Published

cerebro-modeler scans your SQL Server schema and generates clean, type-safe TypeORM entities. Powered by your database. Inspired by Cerebro

Readme

📦 cerebro-modeler

npm version License: MIT written in TypeScript

Database-first entity generator for TypeORM with full control over formatting, imports, and schema introspection.
Built for MSSQL, designed for power users.


🧭 Table of Contents


✨ Features

  • 🔍 Introspects SQL Server schemas
  • 🧠 Generates strongly-typed TypeORM entities
  • 🪶 Auto-formatted using Prettier
  • 🔁 Supports ManyToOne, OneToMany, and bridge tables
  • 🧩 Highly customizable naming strategy
  • ⚡️ CLI-ready via npx cerebro-modeler

📦 Installation (optional)

You can run it via npx without installing, but if you prefer global usage:

yarn global add cerebro-modeler
# or
npm install -g cerebro-modeler

🚀 Quick Start

npx cerebro-modeler --help

🛠️ Usage

npx cerebro-modeler \
  --host localhost \
  --port 1433 \
  --user sa \
  --password MySecret123 \
  --database MyDB \
  --schema dbo \
  --output ./src/entities

If the --tables flag is not provided, the CLI will prompt you interactively:

  • First, it asks whether you want to generate models for all tables in the schema.
  • If you decline, it will ask you to manually enter a comma-separated list of table names.
  • This makes it easy to control which entities are generated without needing to specify --tables up front.

Required Flags

| Flag | Alias | Description | | ------------ | ----- | ------------------- | | --host | -h | SQL Server hostname | | --port | -p | SQL Server port | | --user | -u | DB user | | --password | -x | DB password | | --database | -d | Database name | | --schema | -s | Schema (e.g. dbo) | | --output | -o | Output directory |


🔧 Optional Flags

| Flag | Alias | Description | | ------------------ | ------ | ------------------------------------------------------------------------------------- | | --engine | -e | Database engine (currently only mssql is supported) | | --tables | -t | Comma-separated list of tables to introspect (e.g., users,orders) | | --ignoreTables | -it | Comma-separated list of tables to ignore (e.g., notifications,logs) | | --ssl | | Use SSL connection to the database | | --writeMode | -w | Writing strategy: inline replaces existing files, out saves to separate directory | | --caseFile | --cf | Naming style for file names: pascal, camel, snake, kebab | | --caseClass | --cc | Naming style for class names inside files: pascal, camel, snake | | --caseProperty | --cp | Naming style for field names: camel, pascal, snake | | --prefixFile | --pf | Add prefix to file names (e.g., "I"IUser.ts) | | --prefixClass | --pc | Add prefix to class names (e.g., "I"IUser) | | --prefixProperty | --pp | Add prefix to property names (e.g., "_"_createdAt) | | --suffixFile | --sf | Add suffix to file names (e.g., "Model"UserModel.ts) | | --suffixClass | --sc | Add suffix to class names (e.g., "Model"UserModel) | | --suffixProperty | --sp | Add suffix to property names (e.g., "_"createdAt_) | | --fileExtension | --fe | Add a suffix to file names before .ts (e.g., "entity"user.entity.ts) |


🔤 Naming Strategy

You can customize how files, classes, and properties are named using:

  • --caseFile, --prefixFile, --suffixFile, --fileExtension
  • --caseClass, --prefixClass, --suffixClass
  • --caseProperty, --prefixProperty, --suffixProperty

File Naming Behavior

The final file name is composed like this:

[prefix][BaseName][suffix][.fileExtension].ts

Example:

--caseFile kebab --prefixFile i --suffixFile model --fileExtension entity
# → i-user-model.entity.ts

The --fileExtension does not affect the class name. It is appended before .ts and treated as a true extension, not as a suffix for casing.


✍️ Inline Mode

Use --write-mode inline to overwrite entities directly in your existing project.
Useful for regenerating up-to-date models without touching unrelated files.


🧪 Advanced Usage

Generate models with snake_case files and camelCase properties:

npx cerebro-modeler \
  --host localhost \
  --user sa \
  --password MySecret123 \
  --database MyDB \
  --tables users,orders \
  --ignoreTables notifications \
  --caseFile snake \
  --caseProperty camel \
  --fileExtension entity \
  --output ./src/models

🛠 Troubleshooting

  • Missing required flag: If you forget to pass a required flag (like --host), the CLI will prompt you interactively.
  • Tables not generating: Ensure your DB user has permission to read INFORMATION_SCHEMA views.
  • Output is empty: Make sure the specified schema and table names are correct.

📁 Output Example

@Entity('player', { schema: 'dbo' })
export class PlayerEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column('varchar', { length: 255 })
  name: string;

  @OneToMany(() => TournamentEntity, t => t.player)
  tournaments: TournamentEntity[];
}

🧠 Credits

Based on typeorm-model-generator but rebuilt from scratch for full control and extensibility.