Mango::Database - MongoDB database
use Mango::Database; my $db = Mango::Database->new(mango => $mango); my $collection = $db->collection('foo'); my $gridfs = $db->gridfs;
Mango::Database is a container for MongoDB databases used by Mango.
Mango::Database implements the following attributes.
my $mango = $db->mango; $db = $db->mango(Mango->new);
Mango object this database belongs to.
my $name = $db->name; $db = $db->name('bar');
Name of this database.
Mango::Database inherits all methods from Mojo::Base and implements the following new ones.
my $collection = $db->collection('foo');
Get Mango::Collection object for collection.
my $names = $db->collection_names;
Names of all collections in this database. You can also append a callback to perform operation non-blocking.
$db->collection_names(sub { my ($db, $err, $names) = @_; ... }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
my $doc = $db->command(bson_doc(getLastError => 1, w => 2)); my $doc = $db->command('getLastError', {w => 2});
Run command against database. You can also append a callback to run command non-blocking.
$db->command(('getLastError', {w => 2}) => sub { my ($db, $err, $doc) = @_; ... }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
my $gridfs = $db->gridfs;
Get Mango::GridFS object.
my $stats = $db->stats;
Get database statistics. You can also append a callback to perform operation non-blocking.
$db->stats(sub { my ($db, $err, $stats) = @_; ... }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
Mango, Mojolicious::Guides, http://mojolicio.us.
To install Mango, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mango
CPAN shell
perl -MCPAN -e shell install Mango
For more information on module installation, please visit the detailed CPAN module installation guide.