DBIx::...Update(3pm)

πŸ“¦
version 2.037000 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– DBIx::Class::Helper::Row::ProxyResultSetUpdate πŸ’–

okay bestie, gather round, because this one is a lil module with big main character energy. it lives in the DBIx::Class::Helper::Row::ProxyResultSetUpdate corner of the Perl universe (User Contributed Perl Documentation, if you're keeping receipts), and it's about letting your Result reuse the update logic you already wrote in your ResultSet. no cap. πŸ¦‹


✨ SYNOPSIS ✨

so first, the ResultSet β€” you write your update however you want, and this is the moment:

package MyApp::Schema::ResultSet::Foo;

use parent 'DBIx::Class::ResultSet';

sub update {
   my ($self, $data) = @_;

   die 'you fool!' if $data->{name} eq 'fool';

   return $self->next::method($data);
}

(yes, it really does die 'you fool!'. iconic behavior honestly πŸ’€)

then the Result:

package MyApp::Schema::Result::Foo;

use parent 'DBIx::Class::Core';

__PACKAGE__->load_components(qw( Helper::Row::ProxyResultSetUpdate ));

...

or, if you're a DBIx::Class::Candy girlie:

package MyApp::Schema::Result::Foo;

use DBIx::Class::Candy -components => ['Helper::Row::ProxyResultSetMethod'];

...

🌸 DESCRIPTION 🌸

okay so here's the tea β˜•. This module makes reusing resultset updates from a result trivially easy. Like, literally trivial. ✨

the way that people usually share update methods? they override update in their resultset and route it through "update_all" in DBIx::Class::ResultSet. and unfortunately β€” and I cannot stress this enough β€” that can end up being wildly inefficient. 😭

instead: if you can write your update in terms of the resultset, you can make your code much faster and more efficient. that's it, that's the whole vibe. ate. πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>


This software is copyright (c) 2024 by Arthur Axel "fREW" Schmidt.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page bestie 🫢 shoutout to perl v5.40.0, dated 2024-11-16, served up fresh from the User Contributed Perl Documentation collection. go forth and proxy those resultset updates, you absolute icon. β­πŸ§šπŸ’œ

πŸ“¦ where this page comes from