Mojo-Pg 3.02

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

  • 3.02 - February 18, 2017 23:58
  • 3.01 - February 12, 2017 16:04
  • 3.0 - February 11, 2017 20:33
  • 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
See all 68 releases

Project Statistics

SourceRank 11
Dependencies 4
Dependent projects 9
Dependent repositories 0
Total releases 68
Latest release
First release
Stars 58
Forks 30
Watchers 18
Contributors 3
Repo Size: 437 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-02-19 15:39:45 UTC

Login to resync this project