MongoDB::Collection - A Mongo Collection
version 0.01
The name of the collection.
The full_name of the collection, including the namespace of the database it's in.
my $cursor = $collection->query({ i => { '$gt' => 42 } });
Executes the given $query and returns a MongoDB::Cursor with the results.
$query
MongoDB::Cursor
my $object = $collection->find_one({ name => 'Resi' });
Executes the given $query and returns the first object matching it.
my $id = $collection->insert({ name => 'mongo', type => 'database' });
Inserts the given $object into the database and returns its MongoDB::OID.
$object
MongoDB::OID
$collection->update($object);
Updates an existing $object in the database.
$collection->remove({ answer => { '$ne' => 42 } });
Removes all objects matching the given $query from the database.
$collection->ensure_index([qw/foo bar/]);
Makes sure the given @keys of this collection are indexed. The optional index direction defaults to ascending.
@keys
ascending
my $n_objects = $collection->count({ name => 'Bob' });
Counts the number of objects in this collection that match the given $query.
$collection->validate;
Asks the server to validate this collection.
$collection->drop_indexes;
Removes all indexes from this collection.
$collection->drop_index('foo');
Removes an index called $index_name from this collection.
$index_name
my @indexes = $collection->get_indexes;
Returns a list of all indexes of this collection.
$collection->drop;
Deletes a collection as well as all of its indexes.
Florian Ragwitz <rafl@debian.org>
This software is Copyright (c) 2009 by 10Gen.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
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.