express-mvc-generator icon indicating copy to clipboard operation
express-mvc-generator copied to clipboard

Please give samples with mysql connection!

Open congnt46 opened this issue 7 years ago • 3 comments

Could you integrate mysql/sequelizejs into express-mvc? I am confused at database config and sequelizejs integration

congnt46 avatar Feb 03 '18 13:02 congnt46

Sorry for the late reply , I have been a little bit busy with my development work , unable to check your issues . I am developing advanced full-featured ECMAScript based express-mvc-generator(popular template engines, popular databases, popular third-party modules, angular5, react, Profiler, Authentication and Social media integrations ). I will update you once it has done.

Thanks for using express-mvc-generator , Happy Coding.

rajaramtt avatar Feb 06 '18 05:02 rajaramtt

I too would like to see instructions on how to use this with mysql.

dgleba avatar Jan 23 '20 03:01 dgleba

Sorry for the late reply, Just now checked your email, Default I have given MongoDB, if you want you can you MySQL using the below steps.

1)Update database.js

var mysql      = require('mysql');
var connection = mysql.createConnection({ 
   host     : 'localhost',  
   user     : 'root', 
   password : '',  
   database    : ''});
connection.connect(function(err) {
    if (err) { 
       console.error('error connecting: ' + err.stack);    
       return false;
   }
});
module.exports = connection;
  1. Model
 var connection = require('../../config/database');
	 connection.query("SELECT * FROM users WHERE role_id = 4 and isarchived=0", function(err, rows) {
				if (err){
					res.redirect('/err');
				 } 
	
		};

I have been a little bit busy with my development work, unable to check your issues. I am developing advanced full-featured ECMAScript based express-mvc-generator(popular template engines, popular databases, popular third-party modules, angular6, react, Profiler, Authentication and Social media integrations ). I will update you once it has done.

Thanks for using express-mvc-generator , Happy Coding

rajaramtt avatar Jan 27 '20 05:01 rajaramtt