Mojo-Pg 2.35

Mojolicious ♥ PostgreSQL

Homepage: http://mojolicious.org

Platform: CPAN

Language: Perl

License: Artistic-2.0

Repository: https://github.com/kraih/mojo-pg

View on registry: https://metacpan.org/release/Mojo-Pg


Mojo::Pg Build Status

A tiny wrapper around DBD::Pg that makes PostgreSQL a lot of fun to use with the Mojolicious real-time web framework.

use Mojolicious::Lite;
use Mojo::Pg;
use 5.20.0;
use experimental 'signatures';

helper pg => sub { state $pg = Mojo::Pg->new('postgresql://postgres@/test') };

# Use migrations to create a table during startup
app->pg->migrations->from_data->migrate;

get '/' => sub ($c) {

  my $db = $c->pg->db;
  my $ip = $c->tx->remote_address;

  # Store information about current visitor blocking
  $db->query('insert into visitors values (now(), ?)', $ip);

  # Retrieve information about previous visitors non-blocking
  $db->query('select * from visitors limit 50' => sub ($db, $err, $results) {

    return $c->reply->exception($err) if $err;

    $c->render(json => $results->hashes->to_array);
  });
};

app->start;
__DATA__

@@ migrations
-- 1 up
create table visitors (at timestamp with time zone, ip text);
-- 1 down
drop table visitors;

Installation

All you need is a one-liner, it takes less than a minute.

$ curl -L https://cpanmin.us | perl - -M https://cpan.metacpan.org -n Mojo::Pg

We recommend the use of a Perlbrew environment.

Want to know more?

Take a look at our excellent documentation!

Releases

  • 2.35 - January 11, 2017 08:45
  • 2.34 - January 01, 2017 16:00
  • 2.33 - January 01, 2017 15:10
  • 2.32 - January 01, 2017 14:17
  • 2.31 - December 24, 2016 12:02
  • 2.30 - September 05, 2016 14:32
  • 2.29 - August 10, 2016 12:50
  • 2.28 - June 14, 2016 19:26
  • 2.27 - May 21, 2016 21:46
  • 2.26 - April 28, 2016 16:37
See all 65 releases

Project Statistics

SourceRank 11
Dependencies 3
Dependent projects 8
Dependent repositories 0
Total releases 65
Latest release
First release
Stars 55
Forks 28
Watchers 19
Contributors 3
Repo Size: 355 KB

Top Contributors See all

Sebastian Riedel Flavio Poletti Andrey Khozov

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2017-01-13 01:03:45 UTC