NAME
Mango::Database - MongoDB database
SYNOPSIS
use Mango::Database;
my $db = Mango::Database->new(mango => $mango);
my $collection = $db->collection('foo');
DESCRIPTION
Mango::Database is a container for MongoDB databases used by Mango.
ATTRIBUTES
Mango::Database implements the following attributes.
mango
my $mango = $db->mango;
$db = $db->mango(Mango->new);
Mango object this database belongs to.
name
my $name = $db->name;
$db = $db->name('bar');
Name of this database.
METHODS
Mango::Database inherits all methods from Mojo::Base and implements the following new ones.
collection
my $collection = $db->collection('foo');
Get Mango::Collection object for collection.
command
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;