Electron100 / butane

An ORM for Rust with a focus on simplicity and on writing Rust, not SQL
Apache License 2.0
93 stars 13 forks source link

Example for transaction and r2d2 #3

Closed ieow closed 3 years ago

ieow commented 3 years ago

Hi, I am new to rust.

I notice that there is struct Transaction and ConnectionManager for r2d2 in butane document, I am wondering if butane have example/support for transaction and r2d2.

Electron100 commented 3 years ago

Hi ieow. Yes, there is support for both r2d2 and transactions. For a very basic example with r2d2, see butane/tests/r2d2.rs. For transactions, I am just now realizing there isn't a good example or test. Let me see if I can add one tonight. Let me know if there are any particular points of confusion you'd like to see covered.

ieow commented 3 years ago

Thanks for the pointer!

Electron100 commented 3 years ago

I've also just added a couple basic tests with usage of Transaction. https://github.com/Electron100/butane/commit/b4dcc8a4352a935af3de84bb6f6877d5b2890362 Let me know if this helps or if things are still unclear

ieow commented 3 years ago

Thanks! The example is crystal clear for me.

btw, I note that transaction_builder(pg)/transaction_with_behavior(sqlite) is not implemented. I don't think I will use it but just wondering if it will be implemented

Electron100 commented 3 years ago

Since Butane's goal is as a high-level ORM, I don't necessarily plan to support every feature that the underlying database backends could. I don't have any immediate plans to add support for advanced transaction options, but I'm certainly not opposed to it if there's interest.

ieow commented 3 years ago

Thanks for the reply! One more question, if I am correct, butane uses synchronous backend right? Why not use async ?