Query: mongodb::oid
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
MongoDB::OID(3pm) User Contributed Perl Documentation MongoDB::OID(3pm)NAMEMongoDB::OID - A Mongo ObjectIdSYNOPSISIf no "_id" field is provided when a document is inserted into the database, an "_id" field will be added with a new "MongoDB::OID" as its value. my $id = $collection->insert({'name' => 'Alice', age => 20}); $id will be a "MongoDB::OID" 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. Warning: at the moment, OID generation is not thread safe.SEE ALSOCore documentation on object ids: <http://dochub.mongodb.org/core/objectids>.ATTRIBUTESvalue The OID value. A random value will be generated if none exists already. It is a 24-character hexidecimal string (12 bytes). Its string representation is the 24-character string.METHODSto_string my $hex = $oid->to_string; Gets the value of this OID as a 24-digit hexidecimal string. get_time my $date = DateTime->from_epoch(epoch => $id->get_time); Each OID contains a 4 bytes timestamp from when it was created. This method extracts the timestamp. TO_JSON my $json = JSON->new; $json->allow_blessed; $json->convert_blessed; $json->encode(MongoDB::OID->new); Returns a JSON string for this OID. This is compatible with the strict JSON representation used by MongoDB, that is, an OID with the value "012345678901234567890123" will be represented as "{"$oid" : "012345678901234567890123"}".AUTHORKristina Chodorow <kristina@mongodb.org> perl v5.14.2 2011-09-07 MongoDB::OID(3pm)
Related Man Pages |
---|
gssapi::oid(3) - mojave |
gss_test_oid_set_member(3) - hpux |
gssapi::oid5.18(3) - mojave |
gssapi::oid5.12(3) - osx |
mongodb::gridfs(3pm) - debian |
Similar Topics in the Unix Linux Community |
---|
file editting with shell programmin |
Count the distinct list of ids |
json_decode conversion |
Home dir renaming |
What to buy? |