Skip to content

Commit c38d311

Browse files
committed
Funcion que consulta datos a BD
1 parent 443ab41 commit c38d311

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const dotenv = require('dotenv').config()
2+
3+
if(dotenv.error) throw dotenv.error
4+
5+
const c = con => console.log(con)
6+
7+
const pool = require('./database')
8+
9+
// Obtiene usuarios de BBDD para datos del archivo
10+
const getUsers = async () => {
11+
c('Consultando datos...')
12+
const { rows } = await pool.query('SELECT * FROM auth.users')
13+
c(`Consulta exitosa con ${rows.length} filas`)
14+
pool.end()
15+
return rows
16+
}
17+
18+
(async () => {
19+
const users = await getUsers()
20+
})()

0 commit comments

Comments
 (0)