I am trying to use node-orm2 as middleware with Express, the documentation only shows how you can connect to only one database.
I tried to get Express to use two different layers of the middleware, but no luck. For instance,
app.use(orm.express('sqlite://test.db', define: { })); app.use(orm.express('sqlite://test2.db', define: { }));
I directed everything correctly to this get handler:
app.get("/", function (req, res) { var t1 = req.db.models.table1.find(...); var t2 = req.db.models.table2.find(...); res.send([t1,t2]); });
Since the first base is app.use d table1 , the second of find invocations will give
TypeError: Cannot call method 'find' of undefined
... this means that the two define: blocks were not merged, which we would like.
How do I access two databases using node -orm2?
source share