MongoDB::Database - A Mongo Database
Core documentation on databases: http://dochub.mongodb.org/core/databases.
The name of the database.
my @collections = $database->collection_names;
Returns the list of collections in this database.
my $collection = $database->get_collection('foo');
Returns a MongoDB::Collection for the collection called $name within this database.
MongoDB::Collection
$name
my $grid = $database->get_gridfs;
Returns a MongoDB::GridFS for storing and retrieving files from the database. Default prefix is "fs", making $grid-files> "fs.files" and $grid-chunks> "fs.chunks".
MongoDB::GridFS
$grid-
$database->drop;
Deletes the database.
my $err = $db->last_error;
Finds out if the last database operation completed successfully. If the last operation did not complete successfully, returns a hash reference of information about the error that occured.
my $result = $database->run_command({ some_command => 1 });
Runs a command for this database on the mongo server. Throws an exception with an error message if the command fails. Returns the result of the command on success. For a list of possible database commands, see http://www.mongodb.org/display/DOCS/Table+of+Database+Commands.
See also core documentation on database commands: http://dochub.mongodb.org/core/commands.
my $result = $database->eval('function(x) { return "hello, "+x; }', ["world"]);
Evaluate a JavaScript expression on the Mongo server.
Useful if you need to touch a lot of data lightly; in such a scenario the network transfer of the data could be a bottleneck. The $code argument must be a JavaScript function. $args is an array of parameters that will be passed to the function. For more examples of using eval see http://www.mongodb.org/display/DOCS/Server-side+Code+Execution#Server-sideCodeExecution-Using{{db.eval%28%29}}.
Kristina Chodorow <kristina@mongodb.org>
To install MongoDB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MongoDB
CPAN shell
perl -MCPAN -e shell install MongoDB
For more information on module installation, please visit the detailed CPAN module installation guide.