-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueries.js
More file actions
35 lines (30 loc) · 848 Bytes
/
Copy pathqueries.js
File metadata and controls
35 lines (30 loc) · 848 Bytes
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
33
34
35
let promise = require('bluebird');
let options = {
// Initialization Options
promiseLib: promise
};
let pgp = require('pg-promise')(options);
let connectionString = 'postgres://postgres:StrongPass@id8@localhost:5432/puppies';
let db = pgp(connectionString);
// add query functions
module.exports = {
getAllPuppies: getAllPuppies,
// getSinglePuppy: getSinglePuppy,
// createPuppy: createPuppy,
// updatePuppy: updatePuppy,
// removePuppy: removePuppy
};
function getAllPuppies(req, res, next) {
db.any('SELECT * FROM pups')
.then(function (data) {
res.status(200)
.json({
status: 'success',
data: data,
message: 'Retrieved All puppies'
});
})
.catch(function (error) {
return next(error);
});
}