MongoDBx::Bread::Board::Container
version 0.003
use MongoDBx::Bread::Board::Container; # create a container my $c = MongoDBx::Bread::Board::Container->new( name => 'MongoDB', host => $HOST, database_layout => { test => [qw[ foo bar ]], test_too => [qw[ baz gorch ]] } ); # fetch the 'foo' collection # from the 'test' database my $foo = $c->resolve( service => 'MongoDB/test/foo'); # get the MongoDB::Database # object for the 'test' db my $test = $c->resolve( service => 'MongoDB/test_dbh'); # get the MongoDB::Connection # object used for all the above my $conn = $c->resolve( service => 'MongoDB/connection'); # you can also create the container # within an existing Bread::Board config container 'MyProject' => as { # embed the Mongo container ... container( MongoDBx::Bread::Board::Container->new( name => 'MyMongoDB', host => $HOST, database_layout => { test => [qw[ foo bar ]], test_too => [qw[ baz gorch ]] } ) ); # create services that depend # on the MongoDB container service 'foobar' => ( class => 'FooBar', dependencies => { collection => 'MyMongoDB/test/foo' } ); };
This is a subclass of Bread::Board::Container which can be used to provide services for your MongoDB consuming code. It manages your connection and additionally using the database_layout attribute can provide services to access your databases and collections as well.
database_layout
This is inherited from Bread::Board::Container, this defaults to 'MongoDB' in this container.
The hostname passed to MongoDB::Connection, this defaults to 'mongodb://localhost:27017'.
If you want to pass additional parameters to the MongoDB::Connection constructor, just supply them here and they will get merged in with the host and port params.
host
port
This is the name of the MongoDB connection class, it default to MongoDB::Connection, which is what you want to use most of the time, but if you want something else then you put it here.
This is a data structure that represents the databases and collections you want to access. It is a HASH ref where the keys are the database names and the values are ARRAY refs of collection names. The set of sub-containers and services will then be created based on this information. See the SYNOPSIS and the tests for more detailed examples.
SYNOPSIS
This attribute is required.
Stevan Little <stevan.little@iinteractive.com>
This software is copyright (c) 2012 by Infinity Interactive, Inc..
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MongoDBx::Bread::Board::Container, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MongoDBx::Bread::Board::Container
CPAN shell
perl -MCPAN -e shell install MongoDBx::Bread::Board::Container
For more information on module installation, please visit the detailed CPAN module installation guide.