0
我發展與Node.js的web服務,但我會使用MySQL的,我曾經使用MongoDB的,我可以創建一個架構:Node.js中的Mysql模式?
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
mongoose.connect('mongodb://localhost/webservice', function(err) {
if (err) {
throw err;
} else {
console.log('Connected');
}
});
var UserSchema = mongoose.Schema({
name: String,
email: String,
city: String,
age: String
});
var User = mongoose.model('users', UserSchema);
module.exports = User;
但與MySQL?我有下面的代碼:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user: 'root',
password:''
});
connection.connect(function(err){
if(err){
console.log(err);
}
console.log("Connected...");
});
感謝:d
那麼你不能用貓鼬創建一個MySQL架構,如果這是你在問什麼。你需要一些其他的庫。 –
是的模塊是不同的,但與模塊MySQL有什麼辦法來創建一個架構? – Lagul
退房http://docs.sequelizejs.com/en/latest/ – Ananth