Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- const { Client } = require('pg');
- const Database = {
- register: (server, options, next) => {
- const db = new Client({
- user: 'db_user',
- host: 'host',
- database: 'db_name',
- password: 'db_pass',
- port: 5432, // default PgSQL port
- ssl: true // force SSL
- })
- db.connect()
- server.app.PgSQL = function(){
- return db;
- };
- next();
- }
- }
- Database.register.attributes = {
- name: 'Database',
- version: '1.0.0'
- }
- module.exports = Database;
Add Comment
Please, Sign In to add comment