在postgresql数据库的“dbo”模式中,我有一个名为“钱包”的表。当我试图查询它时,我会得到以下错误:
Executing (default): SELECT "wallets_id", "confirmed_balance", "unconfirmed_balance", "created_at", "updated_at" FROM "dbo.wallets" AS "dbo.wallets";
Unhandled rejection SequelizeDatabaseError: relation "dbo.wallets" does not exist这是我的密码:
get_dbo__wallets() : any {
const options = this.getDatabaseDefaultOptions('dbo.wallets');
const entity : types.IObjectWithStringKey = {};
entity['wallets_id'] = {type: Sequelize.UUID, primaryKey: true, allowNull : false};
entity['confirmed_balance'] = Sequelize.BIGINT;
entity['unconfirmed_balance'] = Sequelize.BIGINT;
return this._db.define('dbo.wallets', entity, options);
}
getDatabaseDefaultOptions(tableName : string) : types.IObjectWithStringKey {
const options : types.IObjectWithStringKey = {};
options['timestamps'] = true;
options['createdAt'] = 'created_at';
options['updatedAt'] = 'updated_at';
options['underscored'] = false;
options['paranoid'] = false;
options['deletedAt'] = false;
options['freezeTableName'] = true;
options['tableName'] = tableName;
return options;
}
//and then I call: get_dbo__wallets().all()我应该在模型定义中更改什么以正确设置模式名称?
发布于 2016-05-09 11:09:43
可以使用options对象将架构添加到表定义中:
options['schema'] = 'dbo';我是通过在运行时进入查询创建代码来发现这一点的--它似乎不在文档中。我打开了一个后缀bug来解决以下问题:https://github.com/sequelize/sequelize/issues/5864
https://stackoverflow.com/questions/37110227
复制相似问题