Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. var sql = require('mssql');
  2.  
  3. var config = {
  4. user: 'user',
  5. password: 'password',
  6. server: 'ip',
  7. database: 'database',
  8. connectionTimeout: '5000',
  9. requestTimeout: '5000',
  10. options: {encrypt: true}
  11. };
  12.  
  13. var pool = function(){
  14. var conn = new sql.Connection(config, function(err){
  15. var request = new sql.Request(conn);
  16. //console.dir(request);
  17. return request;
  18. });
  19. return conn;
  20. }
  21.  
  22. module.exports = function(){
  23. return pool;
  24. }
  25.  
  26. function CampanhaDAO(connection){
  27. this._connection = connection;
  28. //console.log(this._connection)
  29. }
  30.  
  31. CampanhaDAO.prototype.getCampanhas = function(){
  32. var sql = "SELECT * FROM notificacao_campanha";
  33.  
  34. this._connection.query(sql, function(err, recordset){
  35.  
  36. console.log(recordset);
  37. });
  38. };
  39.  
  40. module.exports = function(){
  41. return CampanhaDAO;
  42. };
  43.  
  44. module.exports.campanhas = function(app, req, res){
  45. var connection = app.config.dbConnection();
  46. var campanhaDAO = new app.dao.CampanhaDAO(connection);
  47.  
  48. campanhaDAO.getCampanhas(function(error, result){
  49. console.log("gerou");
  50. res.send(result);
  51. });
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement