Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var sql = require('mssql');
- var config = {
- user: 'user',
- password: 'password',
- server: 'ip',
- database: 'database',
- connectionTimeout: '5000',
- requestTimeout: '5000',
- options: {encrypt: true}
- };
- var pool = function(){
- var conn = new sql.Connection(config, function(err){
- var request = new sql.Request(conn);
- //console.dir(request);
- return request;
- });
- return conn;
- }
- module.exports = function(){
- return pool;
- }
- function CampanhaDAO(connection){
- this._connection = connection;
- //console.log(this._connection)
- }
- CampanhaDAO.prototype.getCampanhas = function(){
- var sql = "SELECT * FROM notificacao_campanha";
- this._connection.query(sql, function(err, recordset){
- console.log(recordset);
- });
- };
- module.exports = function(){
- return CampanhaDAO;
- };
- module.exports.campanhas = function(app, req, res){
- var connection = app.config.dbConnection();
- var campanhaDAO = new app.dao.CampanhaDAO(connection);
- campanhaDAO.getCampanhas(function(error, result){
- console.log("gerou");
- res.send(result);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement