Ubuntu Manpages

Catmandu::Store::MongoDB

A searchable store backed by MongoDB

    # On the command line
    $ catmandu import -v JSON --multiline 1 to MongoDB --database_name bibliography --bag books < books.json
    $ catmandu export MongoDB --database_name bibliography --bag books to YAML
    $ catmandu count MongoDB --database_name bibliography --bag books --query '{"PublicationYear": "1937"}'
    # In perl
    use Catmandu::Store::MongoDB;
    my $store = Catmandu::Store::MongoDB->new(database_name => 'test');
    my $obj1 = $store->bag->add({ name => 'Patrick' });
    printf "obj1 stored as %s\n" , $obj1->{_id};
    # Force an id in the store
    my $obj2 = $store->bag->add({ _id => 'test123' , name => 'Nicolas' });
    my $obj3 = $store->bag->get('test123');
    $store->bag->delete('test123');
    $store->bag->delete_all;
    # All bags are iterators
    $store->bag->each(sub { ... });
    $store->bag->take(10)->each(sub { ... });
    # Search
    my $hits = $store->bag->search(query => '{"name":"Patrick"}');
    my $hits = $store->bag->search(query => '{"name":"Patrick"}' , sort => { age => -1} );
    my $hits = $store->bag->search(query => {name => "Patrick"} , start => 0 , limit => 100);
    
    my $next_page = $hits->next_page;
    my $hits = $store->bag->search(query => '{"name":"Patrick"}' , page => $next_page);
    my $iterator = $store->bag->searcher(query => {name => "Patrick"});

A Catmandu::Store::MongoDB is a Perl package that can store data into MongoDB databases. The database as a whole is called a 'store'. Databases also have compartments (e.g. tables) called Catmandu::Bag-s.

The following connection parameters are depreacted and will be removed in a future version of this module:

    - connect_retry
    - connect_retry_sleep

Create a new Catmandu::Store::MongoDB store with name $name. Optionally provide connection parameters (see MongoDB::MongoClient for possible options).

Create or retieve a bag with name $name. Returns a Catmandu::Bag.

Return the MongoDB::MongoClient instance.

Return a MongoDB::Database instance.

Delete the store and all it's bags.

Catmandu::Bag, Catmandu::Searchable , MongoDB::MongoClient

Nicolas Steenlant, "<nicolas.steenlant at ugent.be>"

Johann Rolschewski, "<jorol at cpan.org>"

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.