Database for node js

Last updated: August 14, 2020

ORM

Sequelize

  • Bad support
  • Bugs
  • Not maintained much anymore

Typeorm

  • Clean syntax
  • Needs to use decorators

Objection.js

  • A bit verbose static get tableName() {, static get idColumn() {
  • Table is created manually await knex.schema.createTable('persons', table => { not from your model definition
  • Complex docs. First example is doing a withGraphFetched query! Wtf. 2nd docs are even more convoluted. I give up. I just wanted a simple query + maybe a join.
  • Old style const { Model } = require('objection');

Query builders

knex.js

  • Not very good typescript support: "However it is to be noted that TypeScript support is currently best-effort. Knex has a very flexible API and not all usage patterns can be type-checked and in most such cases we err on the side of flexibility."
  • weird syntax to create tables
knex.schema.createTable('users', (table) => {
  table.increments();
  table.string('first_name');
});

Raw SQL

Slonik

  • Passing SQL strings: if I rename a table/field, good luck remembering to change all instances of that field in the SQL strings
  • Protecting against unsafe value interpolation
  • Not a lot of support, new project

pg / pg-promise

  • Good support

Contents