Before coming this part of tutorial, we never talked about the database. Actually it was a basic course so I never tell anything about the database. Just wanted to make pure node js tutorial.
Today we’re going to learn how can we add a sql database with express js.
It’s pretty easy, but we need a npm package for it. Actually multiple package for it.
For the sql connection. There are some packages
- Knex.js
- Sqorn
- squel
- Objection.js and many more I personally used knex.js and objection.js. Objection actually based on knex, it has some extra benefits so I used it some projects.
Knex is good choice, beacause it has an amazing documentation. Which is pretty easy to follow.
Installing is pretty easy. As like others. But you need to install the database too. Like what you are using – mysql or postgresql or sqlite
Connecting is easy too, just changing the credentials will be okay.
You can write RAW sql with the knex too. http://knexjs.org/#Raw-Expressions
which one you want to use ?
You can see the graphical version here
Originally it published on nerdjfpbblog. You can connect with me in twitter or linkedin !
Top comments (0)