Database Transactions #316

asymetrixs opened this Issue Feb 17, 2013 · 4 comments


None yet
3 participants


I plan to use geddy for a project in the future but I need database transaction handling. I will use PostgreSQL and need a way to open a transaction, perform several SQL queries (insert/update) and close the transaction afterwards. Unfortunately I haven't found any information about transaction handling. Is it possible to work with database transactions using geddy?


mde commented Feb 18, 2013

Geddy's model layer is handled by the Model project ( The Postgres adapter exposes an exec method which lets you run arbitrary SQL commands and get the results in a callback. It follows the Node convention of (err, data) for the callback.

You should be able to use this method to run any arbitrary SQL commands you want, including transactions.

Looking at the code, I notice that Geddy doesn't give you direct access to Model's Postgres adapter -- you have to access it by the associated model (e.g., geddy.model.adapters.Foo, if you've set the Foo model to use Postgres). It would be simple to have Geddy expose all the loaded adapters by name on a public property of geddy.model.

Let me know if this gets you unstuck. Definitely not the ideal way to handle transactions, but it should work.


mde commented Feb 18, 2013

I've created a GH issue for the grabbing a ref to the adapter: mde#317

That sounds great, thank you!


larzconwell commented Jun 13, 2013

Closing in favor of #317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment