Skip to content

Instantly share code, notes, and snippets.

@guilsa
Last active December 22, 2021 17:30
Show Gist options
  • Save guilsa/0cdd1258c46edf3112b2cc50af03fc8c to your computer and use it in GitHub Desktop.
Save guilsa/0cdd1258c46edf3112b2cc50af03fc8c to your computer and use it in GitHub Desktop.
Node.js database tools (notes)

better-sqlite3

  • great for prototyping all kinds of apps (non production usages) or unit testing
  • pretty good experience with raw queries

sequelize

  • it's an orm, so boooo!
  • plug n play
  • creation of models feels mandatory (sequelize-auto can be used to auto-generate your models if there's an existing db)
  • there is no pluck() to flatten queries like select * from table1 (currently resolving this by writing out another variable for every query)

knex

  • plug n play
  • seems to be pretty robust as a query builder
  • not ideal for raw queries, but seems to have excellent js apis to interact with your db
  • liked the doc

node-postgres (pg)

  • popular postgres driver, useful for raw queries or if you hate orm's
  • didn't expect simple queries to take up so many lines
  • mixes js/sql syntax in a weird way, still getting used to it
    • things like inserting ain't pretty, you're on your own here (was hoping for some helper functions)
  • weird looking async/await statements at times (it's probably just me...)

pg-promise

  • wrapper around node-postgres (pg)
  • still produces weird looking code
  • worth reconsidering

pg-loader

  • not a nodejs project, but worth mentioning as it may be useful to some wishing to migrate dbs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment