I am trying to integrate Knex (which I used on a previous app that did not use kraken.js), but I need it now for my ORM (bookshelf.js). I came across this post while researching, but I'm still a little fuzzy. This is for a mysql DB.
Where should I create the connection so I can pass it to the bookshelf object for my models?
Just set it as a global object in your
onconfig()handler. Something like this:config.json:
lib/bs.js
index.js:
When you need your bookshelf object to define your models, you can include it and it's ready to go:
models/accounts.js
There's other ways to do it, but this is clean and should suffice for what you need.