Group
Extension

Matches 3

Mojo-SQLite ( D/DB/DBOOK/Mojo-SQLite-3.009.tar.gz, DBOOK, 2022; MetaCPAN )
Mojo-SQLite/lib/Mojo/SQLite.pm ( view source; MetaCPAN )
'names', {name => 'Daniel'})->last_insert_id;
  
  # JSON roundtrip
  say $db->query('select ? as foo', {json => {bar => 'baz'}})
    ->expand(json => 'foo')->hash->{foo}{bar};

  # Select one row at 
te->new('sqlite:test.db') };

  get '/' => sub ($c) {
    my $db = $c->sqlite->db;
    $c->render(json => $db->query(q{select datetime('now','localtime') as now})->hash);
  };

  app->start;

In this 
additional features to the L<SQL::Abstract>
query methods in L<Mojo::SQLite::Database> such as C<-json> and
C<limit>/C<offset>. The C<for> feature is not applicable to SQLite queries.

  $sql->db->sel
Mojo-SQLite ( D/DB/DBOOK/Mojo-SQLite-3.009.tar.gz, DBOOK, 2022; MetaCPAN )
Mojo-SQLite/lib/Mojo/SQLite/Results.pm ( view source; MetaCPAN )
package Mojo::SQLite::Results;
use Mojo::Base -base;

use Mojo::Collection;
use Mojo::JSON 'from_json';
use Mojo::Util 'tablify';

our $VERSION = '3.009';

has [qw(db sth)];

sub new {
  my $self = sh
  my @json_names = keys %{$self->{expand}{json}};
    for my $r (@rows) { $r->{$_} = from_json $r->{$_} for grep { $r->{$_} } @json_names }
  } else {
    my $cols = $self->columns;
    my @json_idxs 
= grep { $self->{expand}{json}{$cols->[$_]} } 0..$#$cols;
    for my $r (@rows) { $r->[$_] = from_json $r->[$_] for grep { $r->[$_] } @json_idxs }
  }
  
  return @rows;
}

1;

=head1 NAME

Mojo::SQLi
Mojo-SQLite ( D/DB/DBOOK/Mojo-SQLite-3.009.tar.gz, DBOOK, 2022; MetaCPAN )
Mojo-SQLite/lib/Mojo/SQLite/Database.pm ( view source; MetaCPAN )
tabase;
use Mojo::Base -base;

use Carp qw(croak shortmess);
use DBI 'SQL_VARCHAR';
use Mojo::JSON 'to_json';
use Mojo::Promise;
use Mojo::SQLite::Results;
use Mojo::SQLite::Transaction;
use Mojo::Uti
ists $param->{json}) {
        $sth->bind_param($i+1, to_json($param->{json}), SQL_VARCHAR);
      } elsif (exists $param->{-json}) {
        $sth->bind_param($i+1, to_json($param->{-json}), SQL_VARCH
AR);
      } else {
        croak qq{Unknown parameter hashref (no "type"/"value", "json" or "-json")};
      }
    } else {
      $sth->bind_param($i+1, $param);
    }
  }
  return $sth;
}

1;

=enco

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.