Created
August 15, 2012 11:35
-
-
Save tudorconstantin/3359395 to your computer and use it in GitHub Desktop.
generic REST update with Mojolicious and DBIx::Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub update{ | |
my $self = shift; | |
my $result_rs = $self->app->model | |
->resultset( $self->{resource} ) | |
->search_rs( | |
{ id => $self->param('id') }, | |
); | |
return $self->render_not_found if ( scalar( ( $result_rs->all ) ) == 0 ); | |
$result_rs->update_all( $self->{_payload} ); | |
$result_rs->result_class('DBIx::Class::ResultClass::HashRefInflator'); | |
my @result = $result_rs->all(); | |
return $self->render_json( @result ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment