Why is mongoose typed so loosely?

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

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • 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, MS SQL Server, PostgreSQL and SQLite/libSQL 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/

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • 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 and CockroachDB

  • 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