Defines Mongoose schemas and models from TypeScript classes using decorators, keeping types and database shape in one place.
Overview
Typegoose is a library for defining Mongoose models with TypeScript classes instead of parallel interface and schema files. Decorators such as prop mark fields on a class; reflection reads property types so Mongoose mappings stay aligned when the model evolves.
The typical pattern replaces hand-written schema boilerplate with a single decorated class. Typegoose aims to reduce duplication when Mongoose models and TypeScript types would otherwise diverge. Documentation states it works with standard Mongoose options and focuses on letting developers concentrate on data shape.
It is published for Node.js projects using Mongoose and MongoDB. Migration guides document upgrades between major versions. Community support includes a Discord server, FAQ, and known-issues list. Quick-start and full docs live on the project site.
Teams already on Mongoose who want stronger TypeScript ergonomics import Typegoose as a dependency and build models from classes rather than maintaining separate schema definitions.
Key features
- Mongoose models from TS classes
- @prop and related decorators
- Reflect-metadata type inference
- Single source for schema and types
- Mongoose option compatibility
- Migration guides between majors
- npm package for Node projects
- Discord community support
Use cases
- Typed MongoDB models in Node
- Reducing schema and interface drift
- Mongoose apps in TypeScript
- ODM layer for REST APIs