Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const http = require('http');
- const { Client } = require('pg');
- const app = express();
- const server = http.createServer(app);
- // Connect and get data from DB
- const client = new Client({
- connectionString: '<CONNECTION>'
- });
- client.connect();
- client.query('SELECT * FROM tb_name', function(err, results) {
- // Results
- });
- // Creating object that accept options from DB
- const object = new MyObject({ optionFromDB });
- object.on('ready', () => {
- // Do something when ready
- });
- server.listen(8000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement