I'm working on an application already developed developed in Node.js / Expressjs.
At the moment my problem is: 95% of the application uses schema A , but the new module I'm creating needs to use schema B .
How do I make this change at run time without changing config.js . Unless there is a configuration in it that does not impact the application.
System query example:
var query = "select * from " + config.bd.schema + ".user_types ;";
The new queries should look like this:
var query = "select * from b.user_types ;";
Error I'm getting
Report.js - getData() >>> column_3 >>> select * from dash.user_types where column_3 = 777
/home/patrick/Workspace/company/project/admin/proj/models/Report.js:69
if(err) throw err;
^
error: syntax error at or near "select"
at Connection.parseE (/home/patrick/Workspace/company/project/admin/proj/node_modules/pg/lib/connection.js:534:11)
at Connection.parseMessage (/home/patrick/Workspace/company/project/admin/proj/node_modules/pg/lib/connection.js:361:17)
at Socket.<anonymous> (/home/patrick/Workspace/company/project/admin/proj/node_modules/pg/lib/connection.js:105:22)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
config.js
module.exports={
port: 3002,
base: "/",
elms_por_pag:5,
session_timeout:30,
bd:{
host:'localhost',
user:'****',
password:'****',
database:'*****',
schema:'a'
},
email:{
link_email:"http://projetos.exemplo.com.br",
debug:false,
host:"",
port:0,
name:"Projeto",
secure:true,
username:"",
password:""
}
}
If you need more information let me know.