Group
Extension

Matches 4

Mojo-Pg ( S/SR/SRI/Mojo-Pg-4.28.tar.gz, SRI, 2025; MetaCPAN )
Mojo-Pg/lib/Mojo/Pg.pm ( view source; MetaCPAN )
('names', {name => 'Daniel'}, {returning => 'id'})->hash->{id};

  # JSON roundtrip
  say $db->query('SELECT ?::JSON AS foo', {json => {bar => 'baz'}})
    ->expand->hash->{foo}{bar};

  # Select all 
postgresql://postgres@/test') };

  get '/' => sub ($c) {
    my $db = $c->pg->db;
    $c->render(json => $db->query('SELECT NOW() AS now')->hash);
  };

  app->start;

In this example application, we
state $time = MyApp::Model::Time->new(pg => shift->pg) };

  get '/' => sub ($c) {
    $c->render(json => $c->time->now);
  };

  app->start;

=head1 EXAMPLES

This distribution also contains two grea
Mojo-Pg ( S/SR/SRI/Mojo-Pg-4.28.tar.gz, SRI, 2025; MetaCPAN )
Mojo-Pg/lib/Mojo/Pg/PubSub.pm ( view source; MetaCPAN )
package Mojo::Pg::PubSub;
use Mojo::Base 'Mojo::EventEmitter';

use Mojo::JSON   qw(from_json to_json);
use Scalar::Util qw(weaken);

has pg => undef, weak => 1;
has reconnect_interval => 1;

sub db {
_;
      return unless my $cbs = $self->{chans}{$name};
      $payload = eval { from_json $payload } if $self->{json}{$name};
      for my $cb (@$cbs) { $self->$cb($payload) }
    }
  );

  $db->once(


  return $db;
}

sub DESTROY { shift->reset unless ${^GLOBAL_PHASE} eq 'DESTRUCT' }

sub json { ++$_[0]{json}{$_[1]} and return $_[0] }

sub listen {
  my ($self, $name, $cb) = @_;
  $self->db->list
Mojo-Pg ( S/SR/SRI/Mojo-Pg-4.28.tar.gz, SRI, 2025; MetaCPAN )
Mojo-Pg/lib/Mojo/Pg/Results.pm ( view source; MetaCPAN )
package Mojo::Pg::Results;
use Mojo::Base -base;

use Mojo::Collection;
use Mojo::JSON qw(from_json);
use Mojo::Util qw(tablify);

has [qw(db sth)];

sub DESTROY {
  my $self = shift;
  return unless 
dx) {
    my $types = $self->sth->{pg_type};
    my @idx   = grep { $types->[$_] eq 'json' || $types->[$_] eq 'jsonb' } 0 .. $#$types;
    ($idx, $name) = @$self{qw(idx name)} = (\@idx, [@{$self->colu
  for my $r (@rows) { $r->{$_} && ($r->{$_} = from_json $r->{$_}) for @$name }
  }
  else {
    for my $r (@rows) { $r->[$_] && ($r->[$_] = from_json $r->[$_]) for @$idx }
  }

  return @rows;
}

1;

Mojo-Pg ( S/SR/SRI/Mojo-Pg-4.28.tar.gz, SRI, 2025; MetaCPAN )
Mojo-Pg/lib/Mojo/Pg/Database.pm ( view source; MetaCPAN )
tter';

use Carp    qw(croak shortmess);
use DBD::Pg qw(:async);
use Mojo::IOLoop;
use Mojo::JSON qw(to_json);
use Mojo::Pg::Results;
use Mojo::Pg::Transaction;
use Mojo::Promise;
use Mojo::Util qw(mo
 eq 'HASH') {
      if    (exists $param->{-json}) { $param = to_json $param->{-json} }
      elsif (exists $param->{json})  { $param = to_json $param->{json} }
      elsif (exists $param->{type} && e
ly> for next L</"query"> call and allow C<?> to be used as an operator.

  # Check for a key in a JSON document
  $db->dollar_only->query('SELECT * FROM foo WHERE bar ? $1', 'baz')
    ->expand->hashe

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