Knex.Js. Beginner’s Guide in Examples

Artem Diashkin
LITSLINK
Published in
8 min readJul 14, 2020

--

How to use Knex.js library for fetching data from your database? Let’s find out.

For our purposes, we will be using the simplest Express.js project with PostgreSQL database container in Docker.

1. Starting a new project

If you already have your own project you can skip this part and pass to section “2. Knex.js”

What to expect from this part?

  • running local instance of PostgreSQL Docker container
  • database tables with fake data
  • Express.js application, which will allow us to fetch required data from the database using Knex.js.

--

--