我想知道如何通过 ORM 适配器使用 Node.js 在 MySQL 中创建多个表。我通过模型创建了一个表,即“us.js”
module.exports = {
identity: 'us',
connection: 'mysqlDB',
schema:true,
migrate: 'safe',
attributes: {
as_a: 'string',
i_want_to: 'string',
for_the:'string',
so_that:'string'
}
};
并将其连接构建为 connections.js:
var mysqlAdapter = require('sails-mysql');
var mongoAdapter = require('sails-mongo');
module.exports = {
adapters: {
mongoAdapt: mongoAdapter,
mysqlAdapt: mysqlAdapter
},
connections: {
mysqlDB: {
adapter: 'mysqlAdapt',
host: 'localhost',
database:'user_stories',
user:'root',
password:'',
supportBigNumbers:true, //true/false
debug:['ComQueryPacket'], //false or array of node-mysql debug
options
trace:true //true/false
}
}
};
那么对于同一个连接,如何在 MySQL 数据库中创建多个表。
为新表创建新模型。在模型中,将您想要的那些属性指定为表中的字段。
Tôi là một lập trình viên xuất sắc, rất giỏi!