rajathavalam / express-mvc-generator

Express' Model View Controller Application Generator.
https://github.com/rajathavalam/express-mvc-generator
MIT License
42 stars 14 forks source link

Please give samples with mysql connection! #6

Open congnt46 opened 6 years ago

congnt46 commented 6 years ago

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

rajaramtt commented 6 years ago

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.

dgleba commented 4 years ago

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

rajaramtt commented 4 years ago

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;

2) 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