NAME
Document::Transform::Backend::MongoDB - Talk to a MongoDB via a simple interface
VERSION
version 1.110400
SYNOPSIS
use Document::Transform::Backend::MongoDB;
my $backend = Document::Transform::Backend::MongoDB->new(
host => $ENV{MONGOD}
database_name => 'foo',
transform_collection => 'transforms',
document_collection => 'documents');
my $doc = $backend->fetch_document('SOME_DOCUMENT');
DESCRIPTION
So you need Document::Transform to talk MongoDB. You're in luck, bucko, because this module is your godsend. And it comes by default! Now, there are a couple of different ways to instantiate this and different levels of attributes that can be filled. You can plug in the collections, you can plug in collection names and a database instance, you can plug in collection names, a database name, and connection instance. And if you don't have any instances then some connection info, database name, and collection names are all you need! So it is like you pick your level of support when calling into a PBS telethon.
PUBLIC_ATTRIBUTES
host
is: ro, isa: Str
host contains the host string provided to the MongoDB::Connection constructor.
connection
is: ro, isa: MongoDB::Connection, lazy: 1
This attribute holds the MongoDB connection object. If this isn't provided and it is accessed, a connection will be constructed using the "host" attribute.
database_name
is: ro, isa: Str
If the collections are not provided, this attribute must be provided as a means to access the collections named in the "transform_collection" and "document_collection"
database
is: ro, isa: MongoDB::Database, lazy: 1
This attribute holds the MongoDB data in which the transform and document collections are held. If this isn't provided in the constructor, one will be constructed using the value from "database_name". If there is no value, an exception will be thrown.
document_collection
is: ro, isa: Str
If a collection is not passed to "documents", this attribute will be used to access a collection from the "database".
documents
is: ro, isa: MongoDB::Collection, lazy: 1
This attribute holds the collection from MongoDB that should be the documents that should be fetched for transformation. If a collection is not passed to the constructor, one will be pulled from the database using the value from "document_collection"
transform_collection
is: ro, isa: Str
If a collection is not passed to "transforms", this attribute will be used to access a collection from the "database".
transforms
is: ro, isa: MongoDB::Collection, lazy: 1
This attribute holds the collection from MongoDB that should be the transforms that should be fetched for transformation. If a collection is not passed to the constructor, one will be pulled from the database using the value from "transform_collection"
PUBLIC_METHODS
fetch_document
(Str)
This method implements the "fetch_document" in Docoument::Transform::Role::Backend method. It takes a single string key that should match a document within the documents collection with the right document_id attribute. See the "SYNOPSIS" in Document::Transform for a description of the expected document format.
fetch_transform
(Str)
This method implements the "fetch_transform" in Docoument::Transform::Role::Backend method. It takes a single string key that should match a transform within the transforms collection with the right transform_id attribute. See the "SYNOPSIS" in Document::Transform for a description of the expected transform format.
store_document
This method implements the "Document::Transform::Role::Backend/store_document" method with one key notable option. In addition to the document to store, a second boolean value can be passed to denote whether a "safe" insert/update should take place.
store_transform
This method implements the "Document::Transform::Role::Backend/store_transform" method with one key notable option. In addition to the transform to store, a second boolean value can be passed to denote whether a "safe" insert/update should take place.
AUTHOR
Nicholas R. Perez <nperez@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Infinity Interactive.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.