-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleads.js
40 lines (32 loc) · 1.2 KB
/
leads.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
33
34
35
36
37
38
39
40
var db = require('./pghelper'),
//config = require('./config'),
winston = require('winston');
function findAll(limit) {
return db.query('Select firstname, lastname, title, company, phone, email, leadsource from salesforce.lead ORDER BY CREATEDDATE DESC LIMIT $1', [limit]);
};
function findById(id) {
return db.query('Select firstname, lastname, title, company, phone, email, leadsource from salesforce.lead WHERE id=$1', [id], true);
};
function getAll(req, res, next) {
findAll(15)
.then(function (leads) {
//return res.send(JSON.stringify(leads));
//var lead = JSON.stringify(leads);
//console.log ('data from stringify ' + data)
//res.render('pages/leads.jade', { lead: JSON.stringify(leads), title: 'My Leads' });
res.render('pages/leads.jade', { lead: leads, title: 'My Leads' });
})
.catch(next);
};
function getById(req, res, next) {
var id = req.params.id;
findById(id)
.then(function (lead) {
return res.send(JSON.stringify(lead));
})
.catch(next);
};
exports.findAll = findAll;
exports.findById = findById;
exports.getAll = getAll;
exports.getById = getById;