NAME
MorboDB::OID - An object ID in MorboDB
VERSION
version 0.001002
SYNOPSIS
When inserting documents into a collection, if you don't provide an '_id' attribute, this module will create one automatically.
my $id = $collection->insert({ name => 'Alice', age => 20 });
$id
will be a MorboDB::OID
object that can be used to retreive or update the saved document:
$collection->update({ _id => $id }, { age => { '$inc' => 1 } });
# now Alice is 21
To create a copy of an existing OID, you must set the value attribute in the constructor. For example:
my $id1 = MongoDB::OID->new;
my $id2 = MongoDB::OID->new(value => $id1->value);
Now $id1
and $id2
will have the same value.
DESCRIPTION
A MorboDB::OID object uniquely represents a document in a MorboDB::Collection. When you don't provide a documents with the '_id' attribute during insertion, this module will create an ID automatically.
OIDs in MorboDB are created using Data::UUID, so they are 36-characters long and do not resemble OIDs in MongoDB.
ATTRIBUTES
value
A 36-characters long string representation of the OID in conventional UUID format. See UUID on Wikipedia for more information on UUID format.
OBJECT METHODS
to_string()
This really just returns the 'value' attribute.
get_time()
Not implemented. Only returns undef
here.
TO_JSON()
Meant to be called by the JSON family of modules to create a JSON representation of the OID. So, for example, "4162F712-1DD2-11B2-B17E-C09EFE1DC403" will be represented as { "$oid" : "4162F712-1DD2-11B2-B17E-C09EFE1DC403" }
.
my $json = JSON->new->allow_blessed->convert_blessed;
$json->encode(MorboDB::OID->new);
DIAGNOSTICS
This module does not throw any errors of its own.
BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to bug-MorboDB@rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MorboDB.
SEE ALSO
AUTHOR
Ido Perlmuter <ido@ido50.net>
LICENSE AND COPYRIGHT
Copyright (c) 2011, Ido Perlmuter ido@ido50.net
.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either version 5.8.1 or any later version. See perlartistic and perlgpl.
The full text of the license can be found in the LICENSE file included with this module.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.