Skip to main content

NestJS + Mongoose CRUD toolkit

`nest-mongoose-crud` gives you a typed service base, a controller factory, and query helpers that feel native to NestJS and Mongoose.

product.service.ts
@Injectable()
export class ProductService extends BaseCrudService<ProductDocument> {
constructor(
@InjectModel(Product.name)
model: Model<ProductDocument>,
) {
super(model);
}
}

RequestGET /products

200 OK
?isActive=true&sort=-rating&populate=category:name
0results
0msquery time
typedresponse flow
  • Typed CRUD service foundation for NestJS + Mongoose
  • Factory-generated controllers with room for overrides
  • URL-based filtering, sorting, search, pagination, and populate
  • Schema-friendly docs with DTO and controller examples

BaseCrudService

for typed service primitives

createCrudController

for fast controller generation

APIFeatures

for query-driven filtering and population

How it fits together

A small set of primitives, wired around the way NestJS apps already work.

The package focuses on the repetitive layer: model-backed services, generated controllers, and request query parsing. Your own modules, guards, DTOs, and business logic still stay in charge.

01

Define your schema

Start from your Mongoose model and keep your domain shape central.

02

Extend the service

Plug your model into BaseCrudService and inherit the common operations.

03

Generate the controller

Create CRUD endpoints quickly, then override only the behavior you need.

What the docs cover

Built for fast scanning, not just long reading.

The docs keep the API surface practical: start with setup, move into real query examples, then customize controllers and overrides when your app needs more control.

Guide

Zero boilerplate services

Extend BaseCrudService once and keep the rest of your module setup predictable.

Guide

URL-driven querying

Filter, sort, paginate, search, and populate records through a compact query API.

Guide

Controller factory support

Generate CRUD endpoints quickly, then override the pieces that need custom behavior.

Guide

Typed NestJS patterns

Reuse your DTOs, schemas, and guards without losing TypeScript ergonomics.