NAME

Mongoose::Engine - serialization for MongoDB driver

DESCRIPTION

The Mongoose standard engine. Does all the dirty work. Very monolithic. Replace it with your engine if you want.

METHODS

find_one

Just like "find_one" in MongoDB::Collection, but blesses the hash document into your class package.

Also has a handy mode which allows retrieving an _id directly from a BSON:OID or just a string:

   my $author = Author->find_one( '4dd77f4ebf4342d711000000' );

Which expands onto:

   my $author = Author->find_one({
       _id => BSON::OID->new( value => pack( 'H*', '4dd77f4ebf4342d711000000' ) )
   });

find

Just like "find" in MongoDB::Collection, but returns a Mongoose::Cursor of documents blessed into your package.

query

Just like "query" in MongoDB::Collection, but returns a Mongoose::Cursor of documents blessed into your package.

count

Helper and back-compat method to call estimated_document_count() or count_documents() depending on arguments passed.

estimated_document_count

Just like "estimated_document_count" in MongoDB::Collection.

count_documents

Just like "count_documents" in MongoDB::Collection.

delete

Deletes the document in the database.

collapse

Turns an object into a hash document.

expand

Turns a hash document back into an object.

expanded

This is an empty method called by expand() after a document was turned into an object. This was added in version 2 to allow old classes to handle dates on nested types that previously were DateTime objects and now are BSON::Time, but it can be used/abused to any kind of fix to the expanded object.

It's recommended to use with care and alway using method modifiers (after) to allow subclassing and composition.

collection

Returns the MongoDB::Collection object for this class or object.

save

Commits the object to the database.

db

Returns the object's corresponding MongoDB::Database instance.

fix_integrity

Checks all Mongoose::Join fields for invalid references to foreign object ids.