metabase / toucan

A classy high-level Clojure library for defining application models and retrieving them from a DB
Eclipse Public License 1.0
570 stars 49 forks source link

Allow DB to be passed as an argument to models #16

Open weavejester opened 7 years ago

weavejester commented 7 years ago

Can the database be passed as an argument to the models, or does Toucan only support the database connection as a global var?

camsaul commented 7 years ago

currently it only supports the global var but you can bind *db-connection* if you want to use a different database.

it does sound like it could be a useful feature to have, however, so I'll edit the title of this issue accordingly

camsaul commented 7 years ago

this will likely require reworking things a bit since the internal Toucan DB functions all call (db-connection) to get a connection to the current DB

beders commented 6 years ago

I would even go further and separate out the query forming and query execution aspect. This way we could use async DB drivers, since JDBC is not scaling well. A bootstrap function could provide functions that either deliver actual results or futures, depending on the DB drivers used.