There is a process that takes data from one database and replicates it to another. They are on different db platforms. It is intended that knex.js be the middleware. This works under 0.10.0
var first = require("knex")(...);
var second = require("knex").initialize(...);
but complains that initialize is deprecated. Can someone give an example of how to do this in the current version of knex.js?
Enabling Multiple Database ConnectionsPerformance can degrade if you allow too many database connections for the number of processors that are available. Performance might also degrade if you increase the number of database connections to process small amounts of data.
Can we connect multiple database in node JS? According to the fine manual, createConnection() can be used to connect to multiple databases. However, you need to create separate models for each connection/database: var conn = mongoose. createConnection('mongodb://localhost/testA'); var conn2 = mongoose.
Knex is a SQL query builder, mainly used for Node. js applications with built in model schema creation, table migrations, connection pooling and seeding.
Why don't you use same syntax as for first
? I guess that .initialize
is just outdated(deprecated) version of just function call.
var first = require("knex")(firstConfig);
var second = require("knex")(secondConfig);
first.select('*').from('users');
second.select('*').from('table');
And you have 2 different builders (each with different config).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With