postgresql - How do you query a table with a schema in Sequelize.js? -


i have table called 'wallets' in 'dbo' schema of postgresql database. when try query error:

executing (default): select "wallets_id", "confirmed_balance", "unconfirmed_balance", "created_at", "updated_at" "dbo.wallets" "dbo.wallets"; unhandled rejection sequelizedatabaseerror: relation "dbo.wallets" not exist 

this code:

get_dbo__wallets() : {     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 call:  get_dbo__wallets().all() 

what should change in model definition set schema name correctly?

you can add schema table definition using options object:

options['schema'] = 'dbo'; 

i found stepping query creation code @ runtime - doesn't appear in documentation. i've opened sequelize bug address this: https://github.com/sequelize/sequelize/issues/5864


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -