Why is mongoose typed so loosely?

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/typescript

Our great sponsors
  • Scout APM - Less time debugging, more time building
  • SonarQube - Static code analysis for 29 languages.
  • OPS - Build and Run Open Source Unikernels
  • Mongoose

    MongoDB object modeling designed to work in an asynchronous environment.

    Never used it personally. But just having a quick look at their github project...

  • MikroORM

    TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.

    I ended up writing my own ORM (it's a wrapper over Knex). But if I had to pick something off-the-shelf, the next one I'd probably try is https://mikro-orm.io/

  • Scout APM

    Less time debugging, more time building. Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.

  • papr

    MongoDB TypeScript-aware Models

    I also think the typescript support for mongoose leaves much to be desired. A few months ago, papr catched my eye, which looked like it was created from the lack of typesafe ORMs/ODMs for mongoDB.

  • vite

    Next generation frontend tooling. It's fast!

    I also came to the conclusion that mongoose lacks good TypeScript support. I recently have tried papr, that makes a few things better, but it also isn't as typesafe as I wanted it to be. It also didn't work with our vite setup. I got plenty of errors when running the dev server. We now are using papr to https://plexinc.github.io/papr/#/schema?id=schema-updates

  • Prisma

    Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)

    We’ve been using prisma a lot lately, very happy with it’s typescript support.

  • Superstruct

    A simple and composable way to validate data in JavaScript (and TypeScript).

    After switching to TS, I found mongoose (and alternatives like ts-mongoose) not very useful. Depending on how many of mongoose's features you're using, I found it much easier to use the MongoDb Driver directly which already has a fluent ORM-like API and it's typed very well, and then you can use something like superstruct if you need schema validation

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts