NAME

MongoDBx::AutoDeref::DBRef - DBRef representation in Perl

VERSION

version 1.110560

DESCRIPTION

MongoDBx::AutoDeref::DBRef is the Perl space representation of Mongo database references. These ideally shouldn't be constructed manually, but instead should be constructed by the internal MongoDBx::AutoDeref::LookMeUp class.

PUBLIC_ATTRIBUTES

mongo_connection

is: ro, isa: MongoDB::Connection, required: 1

In order to defer fetching the referenced document, a connection object needs to be accessible. This is required for construction of the object.

$id

is: ro, isa: MongoDB::OID, reader: id, required: 1

This is the OID of the object.

$ref

is: ro, isa: Str, reader: ref, required: 1

This is the collection in which this item resides.

$db

is: ro, isa: Str, reader: db, required: 1

This is the database in which this item resides.

lookmeup

is: ro, isa: MongoDBx::AutoDeref::LookMeUp, weak_ref: 1, required: 1

When fetching referenced documents, those documents may in turn reference other documents. By providing a LookMeUp object, those other references can also be travered as DBRefs.

PUBLIC_METHODS

revert

This method returns a hash reference in the DBRef format suitable for MongoDB serialization.

fetch

(HashRef?)

fetch takes the information contained in the "$db", "$ref", "$id" attributes and applies them via the "mongo_connection" to retrieve the document that is referenced.

fetch also accepts a hashref of fields-as-keys that will be passed unaltered directly to the MongoDB driver as a way to limit the fields pulled back.

AUTHOR

Nicholas R. Perez <nperez@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Nicholas R. Perez <nperez@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.