DEV Community

Cover image for Sequelite - a lean TypeScript ORM for NodeJS
Sabbir Siddiqui
Sabbir Siddiqui

Posted on

Sequelite - a lean TypeScript ORM for NodeJS

I have worked with NodeJS + Sequelize for more than 6 years now, and I can conclude two things:

  1. Sequelize is awesome!
  2. Model abstraction in a complex system has diminishing returns

The more complex our systems got, the more we tended to go towards a convention of

> Basic CRUD with ORM Models, complex stuff with raw queries

So, with that convention and my cumulative experience, I released yet another ORM for NodeJS - Sequelite

Yes, the name is a little on the nose.

Just released v1.0.0 of my own #opensource ORM in NodeJS! Link is in the comments.

Sequelite is a lightweight ORM built on top of Sequelize with proper Typescript support, no annotations, no heavy model classes, and easy setup.

The main motivations behind creating this package were having

  1. An easy setup
  2. Full type support for CRUD operations based on a declared TS interface
  3. Common raw queries wrapped around Sequelize and exposing them as generic functions, e.g. bulkUpdate, etc.
  4. Flexible configuration and DB connection through Sequelize
  5. Out of the box support for MySQL and Postgres, but segregated by separate base models considering their query differences

Working with Sequelize in the last few years on several projects, I found the model definitions and setup boilerplate to be a bit clunky, although that is the price to pay for an otherwise awesome ORM.

This project will give you the ability to do basic CRUD queries with full type support, which is convenient. However, in more complex systems and queries, I found raw queries are superior to any ORM wrapper interface since it gives you full control of what you are actually querying, so the client also exposes interfaces for raw select queries.

Already thinking of some improvements, like

  1. declaring an identity column (or columns) within a model class, so internally it will know which ID to use for upsert, or for index related queries.
  2. strengthening the where clause interface

Feedback is welcome!

Checkout the github source here - https://github.com/siddiqus/sequelite

npm - https://www.npmjs.com/package/@siddiqus/sequelite

Top comments (0)