Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const dbClient = require('knex')({
- client: 'pg',
- connection: {
- host: '127.0.0.1',
- user: 'user',
- password: 'password',
- database: 'staging',
- port: '5431'
- }
- })
- module.exports = dbClient
- const knex = require('./dbClient.js')
- async function doThis(email) {
- const last = await knex('users').where({email}).first('last_name').then(res => res.last_name)
- // knex.destroy()
- return last
- }
- async function doThat(email) {
- const first = await knex('users').where({email}).first('first_name').then(res => res.first_name)
- // knex.destroy()
- return first
- }
- module.exports = {
- doThat,
- doThis
- }
- const {doThis, doThat} = require('./libs.js');
- (async () => {
- try {
- const res1 = await doThis('user53@gmail.com')
- console.log(res1)
- const res2 = await doThat('user53@gmail.com')
- console.log(res2)
- } catch (err) {
- console.log(err)
- }
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement