8000 Automatic Transaction commit · Issue #28 · alaisi/postgres-async-driver · GitHub
[go: up one dir, main page]

Skip to content
Automatic Transaction commit #28
Open
@ufoscout

Description

@ufoscout

I wonder if it possible to auto commit a transaction without the need for calling tx.commit().
For example, instead of this:

db.begin()
    .flatMap(tx -> tx.querySet("insert into products (name) values ($1) returning id", "saw")
        .map(productsResult -> productsResult.row(0).getLong("id"))
        .flatMap(id -> tx.querySet("insert into promotions (product_id) values ($1)", id))
        .flatMap(promotionsResult -> tx.commit())
    ).subscribe(
        __ -> System.out.println("Transaction committed"),
        Throwable::printStackTrace);

would it be possible to have this:

boolean autoCommit = true;
db.begin(autoCommit)
    .flatMap(tx -> tx.querySet("insert into products (name) values ($1) returning id", "saw")
        .map(productsResult -> productsResult.row(0).getLong("id"))
        .flatMap(id -> tx.querySet("insert into promotions (product_id) values ($1)", id))
    ).subscribe(
        __ -> System.out.println("Transaction committed"),
        Throwable::printStackTrace);

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0