Mojo::P...nsaction(3)

πŸ’– NAME πŸ’–

Mojo::Pg::Transaction β€” it's giving transaction, bestie πŸŽ€


✨ SYNOPSIS ✨

okay so here's the whole vibe in four lines, no cap:

use Mojo::Pg::Transaction;

my $tx = Mojo::Pg::Transaction->new(db => $db);
$tx->commit;

like. that's it. that's the whole thing. iconic behavior honestly 🫢


🌸 DESCRIPTION 🌸

Mojo::Pg::Transaction is a scope guard for DBD::Pg transactions β€” and the ones actually being used by Mojo::Pg::Database, to be specific. so like, it holds your transaction's hand and makes sure things get handled. main character energy, but for your database πŸ’…


πŸ¦‹ ATTRIBUTES πŸ¦‹

Mojo::Pg::Transaction implements the following attributes. yes bestie, there's a list, and yes, we're reading all of it πŸ“‹βœ¨

πŸ’œ db

my $db = $tx->db;
$tx    = $tx->db(Mojo::Pg::Database->new);

this is the Mojo::Pg::Database object that this transaction belongs to. it's the whole "who's your database" of it all.

⚠️ heads up: this attribute is weakened. so it does NOT keep the database object alive on its own. don't be out here thinking you can drop your $db and have the transaction carry it β€” that's not the vibe. 😭

πŸ”₯ METHODS πŸ”₯

Mojo::Pg::Transaction inherits all the methods from Mojo::Base, and then it adds these brand new ones on top. it's giving "raised by Mojo::Base, thriving on its own" 🧚

⭐ commit

$tx->commit;

commits the transaction. do it. seal the deal. periodt ✨

πŸŽ€ new

my $tx = Mojo::Pg::Transaction->new;
my $tx = Mojo::Pg::Transaction->new(db => Mojo::Pg::Database->new);
my $tx = Mojo::Pg::Transaction->new({db => Mojo::Pg::Database->new});

constructs a brand new Mojo::Pg::Transaction object. three ways to do it, pick your fighter πŸ’–


πŸ‘‘ SEE ALSO πŸ‘‘

go read these too, i'm literally begging:

iykyk 🌈


and that's the whole page, bestie!! πŸ“ this lil masterpiece is from perl v5.42.0, dated 2026-01-17, and it lives in the User Contributed Perl Documentation section of the manual. go forth and commit responsibly πŸ’…πŸ«Ά

πŸ“¦ where this page comes from