teamhackback / hb-ddb

Vibe.d Async native D Postgres client
https://teamhackback.github.io/hb-ddb/docs/ddb/pg.html
1 stars 1 forks source link

Transaction support #2

Open wilzbach opened 7 years ago

wilzbach commented 7 years ago
BEGIN
...
COMMIT

See also: https://github.com/dvigal/ddb/blob/f283ebb3fbb8d3c811a39721cff282587154812f/source/ddb/transaction.d

wilzbach commented 7 years ago

See also:

http://docs.sqlalchemy.org/en/rel_1_1/orm/session_transaction.html?highlight=transaction http://docs.peewee-orm.com/en/latest/peewee/transactions.html?highlight=transaction https://docs.ponyorm.com/transactions.html?highlight=transaction http://knexjs.org/#Transactions http://docs.sequelizejs.com/en/latest/docs/transactions/ http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html

wilzbach commented 7 years ago

The following works now:

// scoped struct with destructor
with (conn.transaction) {
    auto result = query(`SELECT * from "Foo" Limit 1`);
    foreach (row; result)
        writeln(row);
}

// scoped lambda
conn.transaction({
    auto result = conn.query(`SELECT * from "Foo" Limit 1`);
    foreach (row; result)
        writeln(row);
});