使用 Sequelize
使用 Sync 同步 table
程式範例:
const { Sequelize } = require('sequelize');
const dotenv = require("dotenv"); // Import dotenv
dotenv.config(); // Load environment variables from .env file
// Initialize Sequelize with your MySQL connection details
const { DB_USER, DB_PASS, DB_HOST } = process.env;
const sequelize = new Sequelize('db_name', DB_USER, DB_PASS, {
host: DB_HOST,
dialect: 'mysql',
logging: false,
});
module.exports = sequelize;創建資料
使用 Transaction
注意事項
Last updated