How can I pass for example the database reference
nano = require('nano')('http://127.0.0.1:5984')
db = nano.use('database')
to a resource ‘User’ (loaded with express-resource)?
I tried:
app.resource('user', require('./routes/user'), {db: db});
But that doesn’t work.
You want to pass
dbto the user.js routing file. What you are doing is passing it to theapp.resourcefunction.You will have to wrap your user.js file in a function that can receive
dbas a parameter.If you don’t like the way this is structured, you can also use a middleware.