NAME
BSON::ObjectId - ObjectId data element for BSON
VERSION
version 0.15
SYNOPSIS
use BSON;
my $oid = BSON::ObjectId->new;
my $oid2 = BSON::ObjectId->new($string);
my $oid3 = BSON::ObjectId->new($binary_string);
DESCRIPTION
This module is needed for BSON and it manages BSON's ObjectId element.
METHODS
new
Main constructor which takes one optional parameter, a string with ObjectId. ObjectId can be either a 24 character hexadecimal value or a 12 character binary value.
my $oid = BSON::ObjectId->new("4e24d6249ccf967313000000");
my $oid2 = BSON::ObjectId->new("\x4e\x24\xd6\x24\x9c\xcf\x96\x73\x13\0\0\0");
If no ObjectId string is specified, a new one will be generated based on the machine ID, process ID and the current time.
value
Returns or sets the ObjectId value.
$oid->value("4e262c24422ad15e6a000000");
print $oid->value; # Will print it in binary
is_legal
Returns true if the 24 character string passed matches an ObjectId.
if ( BSON::ObjectId->is_legal($id) ) {
...
}
OVERLOAD
The string operator is overloaded so any string operations will actually use the 24-character value of the ObjectId.
THREADS
This module is thread safe.
SEE ALSO
AUTHORS
minimalist <minimalist@lavabit.com>
David Golden <david@mongodb.com>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2015 by minimalist and MongoDB, Inc..
This is free software, licensed under:
The Apache License, Version 2.0, January 2004