database.js
// Function to connect to database and execute query
Function to connect to database and execute query
Function to connect to database and execute query
function executeQuery(query, callback) {
  sequelize
    .query(query, {
      logging: console.log,
      plain: false,
      raw: true,
      type: Sequelize.QueryTypes.SELECT
    })
    .then(function(result) {
      return callback(null, result)
    })
    .catch(function(error) {
      return callback(error, null)
    })
}
function executeQuery ( query , callback ) { sequelize . query ( query , { logging : console . log , plain : false , raw : true , type : Sequelize . QueryTypes . SELECT } ) . then ( function ( result ) { return callback ( null , result ) } ) . catch ( function ( error ) { return callback ( error , null ) } ) }
Function to connect to database and execute query
Function to connect to database and execute query
// A function (or false) for logging your queries // Will get called for every SQL query that gets send // to the server. // If plain is true, then sequelize will only return the first // record of the result set. In case of false it will all records. // Set this to true if you don't have a model definition for your query. // The type of query you are executing. The query type affects how results are formatted before they are passed back.