connect to db with knex

This commit is contained in:
Sorrel Bri 2020-01-07 21:46:24 -08:00 committed by sorrelbri
parent bbdc63f61c
commit c14a76e996
6 changed files with 1329 additions and 1 deletions

View file

@ -0,0 +1,8 @@
const knex = require('knex');
const knexfile = require('../knexfile');
const env = process.env.NODE_ENV || 'development';
const configOptions = knexfile[env];
module.exports = knex(configOptions);

View file

@ -0,0 +1,37 @@
// Update with your config settings.
require('dotenv').config()
module.exports = {
development: {
client: 'postgresql',
connection: process.env.PG_CONNECTION_STRING
},
staging: {
client: 'postgresql',
connection: process.env.PG_CONNECTION_STRING,
migrations: {
directory: './data/migrations',
},
seeds: { directory: './data/seeds' },
pool: {
min: 2,
max: 10
}
},
production: {
client: 'postgresql',
connection: process.env.PG_CONNECTION_STRING,
migrations: {
directory: './data/migrations',
},
seeds: { directory: './data/seeds' },
pool: {
min: 2,
max: 10
}
}
};

View file

@ -0,0 +1,8 @@
exports.up = function(knex) {
};
exports.down = function(knex) {
};

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,10 @@
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
"start": "node ./bin/www",
"make-migration": "./node_modules/.bin/knex migrate:make",
"migrate": "./node_modules/.bin/knex migrate:latest",
"seed": "./node_modules/.bin/knex seed:run"
},
"dependencies": {
"chai": "^4.2.0",
@ -14,6 +17,7 @@
"dotenv": "^8.2.0",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"knex": "^0.20.7",
"morgan": "~1.9.1",
"pg": "^7.17.0",
"socket.io": "^2.3.0"

View file

@ -6,6 +6,8 @@ const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const db = require('./data/db');
const dotenv = require('dotenv');
dotenv.config();