TypeORM MongoDB Review

TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8). Its goal is to always support the latest JavaScript features and provide additional features that help you to develop any kind of application that uses databases — from small applications with a few tables to large scale enterprise applications with multiple databases.

TypeORM supports both Active Record and Data Mapper patterns, unlike all other JavaScript ORMs currently in existence, which means you can write high quality, loosely coupled, scalable, maintainable applications the most productive way.

@CreateDateColumn({ type: 'timestamp' })createdAt: Date@UpdateDateColumn({ type: 'timestamp', nullable: true  })updatedAt?: Date

We can’t go with such changes. If we keep going with mongodb-specific changes entity-manager/repository is going to be a mess for rdbms and we’ll always be blocked on some absolute incompatible features.

I suggest to remove dependency of MongoEntityManager from EntityManager (e.g. remove extends) and completely re-implement MongoEntityManager with mongodb-specific features.

import { ObjectID } from 'mongodb'export const toObjectId = (value: string | ObjectID): ObjectID => {  return typeof value === 'string' ? new ObjectID(value) : value}

About Me

Newsletter

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store