0
有聽說我使用sequelize NPM我的SQL datbase sequelize NPM
const Sequelize = require('sequelize');
var sequelize = new Sequelize('custom_crm', 'root', '', {
host: "localhost",
port: 3306,
dialect: 'mysql'
});
sequelize.authenticate().then(() => {
console.log('Connection has been established successfully.');
}).catch((err) => {
console.log('Unable to connect to the database:', err);
});
sequelize.query("SELECT id,name FROM `asd123`.`items` WHERE id = 5 LIMIT 1").spread((results, metadata) => {
console.log("results >>",results);
});
我想轉換asd123(數據庫)查詢使用下面sequelize模式類型連接MySQL數據庫。
website_videos = sequelize.define('website_video', {
id: { type: Sequelize.INTEGER, autoIncrement: true, primaryKey: true },
name : { type: Sequelize.CHAR}
});
website_videos.findAll({}).then((data) => {
console.log('data',data[0]['dataValues']);
}).catch((err) => {
console.log('Unable to connect to the database:', err);
});