安装:

    1. npm i mysql
    1. var mysql = require('mysql');
    2. // 创建连接
    3. var connection = mysql.createConnection({
    4. host : 'localhost',
    5. user : 'root',
    6. password : 'root',
    7. database : 'letao'(这里是仓库)
    8. });
    9. // 连接数据库
    10. connection.connect();
    11. // 执行数据操作
    12. // connection.query('sql 语句')
    13. connection.query('SELECT * from user', function (error, results, fields) {
    14. if (error) throw error;
    15. console.log('The solution is: ', results[0]);
    16. });
    17. // 关闭连接
    18. connection.end();

    Sequelize.js : http://docs.sequelizejs.com/manual/getting-started.html

    创建连接对象