Subject: | MongoDB::DataTypes documentation problem |
Date: | Mon, 07 Mar 2011 13:11:07 -0600 |
To: | bug-MongoDB [...] rt.cpan.org |
From: | James Meek <jmeek [...] vailsys.com> |
The 'Kristina Chodorow > MongoDB-0.32 > MongoDB::DataTypes' documentation for the Perl interface misleadingly
gives the syntax for creating a MongoDB::OID from an existing 24-character hexadecimal string as:
my $oid = MongoDB::OID->new("123456789012345678901234");
In fact, this creates a new, unique ObjectId.
The correct syntax for cloning an existing ObjectId from its character-string representation
(per 'Kristina Chodorow > MongoDB-0.42 > MongoDB::OID', which is correct), is:
my $oid = MongoDB::OID->new( { value => "123456789012345678901234" });
So far, the only way I have found to re-access a MongoDB object using the 24-character representation
of its '_id' is to use syntax such as:
$db->theCollectionName->find_one( {'_id' => MongoDB::OID->new( value => $objId_24_char_representation ) } )
It would seem like a good idea to add this (or any better method that might exist) to the Tutorial.