April 2020
Intermediate to advanced
292 pages
6h 50m
English
Message DB is Just PostgreSQL™, so connecting to it is the same as connecting to PostgreSQL. Now, we’ve been using knex for our database connections up to this point because we were writing our own schema migrations. Message DB ships with a schema that we won’t touch, so we don’t need knex for that. We’ll just use the pg package,[30] a lower-level interface into PostgreSQL. Let’s write the wrapper code for dealing with this library that we punted on last chapter:
| | const Bluebird = require('bluebird') |
| | const pg = require('pg') |
| | |
| | function createDatabase ({ connectionString }) { |
| ① | const client = new pg.Client({ connectionString, Promise: Bluebird }) |
| | |
| ② | let connectedClient ... |
Read now
Unlock full access