helper insertOne => sub { my ($c,$table) = @_; $c->sqlite->db->insert($table, $c->element); };--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
RaiseError is automatically enabled, so use eval or Try::Tiny to catch them. "helper insertOne => sub { my ($c,$table) = @_; $c->sqlite->db->insert($table, $c->element); };
helper deleteOne => sub {
my ($c,$table,$param) = @_; $c->sqlite->db->delete($table, {$tables->{$table} => $param}); };del '/api/select/:table/:id' => sub {
my $c = shift; if ($c->selectOne($c->param('id'))) { eval { $c->deleteOne($c->param('table'),$c->param('id')) }; unless($@) { $c->render(status => 200, json => {message => $c->param('id') . $messages->{'Del'}}); } elsif ($@ =~ /FOREIGN KEY constraint failed/) { $c->render(status => 400, json => {message => $c->param('id') . $messages->{'FK'}}); } } else { $c->render(status => 404, json => {message => "Not found"}); }
};To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/e3480fbb-d830-461f-b644-33f3de62db18%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mojol...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/31a95d6e-acdf-429c-b8d0-1cf059338ad5%40googlegroups.com.