-
Notifications
You must be signed in to change notification settings - Fork 0
/
queries.js
32 lines (27 loc) · 916 Bytes
/
queries.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require('dotenv').config();
const { Pool } = require('pg');
connectionString = {
connectionString: process.env.DATABASE_URL,
ssl: { rejectUnauthorized: false }
};
const pool = new Pool(connectionString);
const queries = {
initialize: async() => {
const client = await pool.connect();
client.release();
console.log('Connected to db');
},
getDayBirthdays: async() => {
let query = "SELECT " +
" nome, aniversario " +
"FROM " +
" public.nivers " +
"WHERE date_part('month', aniversario) = date_part('month', now()) " +
" and date_part('day', aniversario) = date_part('day', now()) " +
"ORDER BY " +
" nome ASC";
const result = await pool.query(query);
return result.rows;
}
}
module.exports = queries;