Debian Codegraph @

/

debian libmango-perl 1.30-2debian libmango-perl cpan Mango 1.30 debianjsonmakefilemarkdownperlshellyaml 45 files · 404 symbols
View dependency graph

Depends on

  • perl (perl)
  • debhelper-compat, libmojolicious-perl
README (full)

Pure-Perl non-blocking I/O MongoDB driver, optimized for use with the Mojolicious real-time web framework.

use Mojolicious::Lite;
use Mango;
use Mango::BSON ':bson';

my $uri = 'mongodb://<user>:<pass>@<server>/<database>';
helper mango => sub { state $mango = Mango->new($uri) };

# Store and retrieve information non-blocking
get '/' => sub {
  my $c = shift;

  my $collection = $c->mango->db->collection('visitors');
  my $ip         = $c->tx->remote_address;

  # Store information about current visitor
  $collection->insert({when => bson_time, from => $ip} => sub {
    my ($collection, $err, $oid) = @_;

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

    # Retrieve information about previous visitors
    $collection->find->sort({when => -1})->fields({_id => 0})->all(sub {
      my ($collection, $err, $docs) = @_;

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

      # And show it to current visitor
      $c->render(json => $docs);
    });
  });
};

app->start;

Installation

All you need is a oneliner, it takes less than a minute.

$ curl -L cpanmin.us | perl - -n Mango

We recommend the use of a Perlbrew environment.

dir debian/
dir lib/
dir t/
file CONTRIBUTING.md
file Changes
file LICENSE
file MANIFEST
file MANIFEST.SKIP
file META.json
file META.yml
file Makefile.PL
file README.md