Writing tests for a node.js server? You should test the database too. Here are a few helper functions for testing a postgres database, using knex.
An example of how to use the pg-large-object package with Knex to allow for streaming Large Objects from a PostgreSQL database in a Node.js program.
A pattern to generate SQL queries using higher order functions, and leverage them to make our Knex query builders modular, concise, and easy to understand.
The moral of the story is, don’t call callbacks from inside promises in NodeJS. They will swallow your exceptions unexpectedly.