/**
 * 数据库连接代理
 * 从 Framework 获取 Sequelize 实例
 */

const Framework = require("../framework/node-core-framework.js");

module.exports = new Proxy({}, {
  get(_, prop) {
    const models = Framework.getModels();
    
    if (!models) {
      throw new Error('Framework not initialized. Please call Framework.init() first.');
    }
    
    const db = {
      sequelize: models.sequelize || global.sequelize,
      Sequelize: models.Sequelize
    };
    
    return db[prop];
  }
});

