text: const { Sequelize, DataTypes } = require("sequelize");
  
  // 从环境变量中读取数据库配置
  const { MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_ADDRESS = "" } = process.env;
  
  const [host, port] = MYSQL_ADDRESS.split(":");
  
  const sequelize = new Sequelize("nodejs_demo", MYSQL_USERNAME, MYSQL_PASSWORD, {
    host,
    port,
    dialect: "mysql" /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */,
  });
  
  // 定义数据模型
  const User = sequelize.define("User", {
    username: {
      type: DataTypes.STRING,
      allowNull: false,
      primaryKey: true
    },
    password: {
      type: DataTypes.STRING,
      allowNull: false
    },
    chinesename: {
      type: DataTypes.STRING,
      allowNull: false
    }
  });
  
  // 数据库初始化方法
  async function init() {
    await User.sync({ alter: true });
  }
  
  // 导出初始化方法和模型
  module.exports = {
    init,
    User,
  };
  