DOKK / manpages / debian 10 / libmango-perl / Mango::BSON::ObjectID.3pm.en
Mango::BSON::ObjectID(3pm) User Contributed Perl Documentation Mango::BSON::ObjectID(3pm)

Mango::BSON::ObjectID - Object ID type

  use Mango::BSON::ObjectID;
  my $oid = Mango::BSON::ObjectID->new('1a2b3c4e5f60718293a4b5c6');
  say $oid->to_epoch;

Mango::BSON::ObjectID is a container for the BSON object id type used by Mango::BSON.

Mango::BSON::ObjectID inherits all methods from Mojo::Base and implements the following new ones.

  my $oid = $oid->from_epoch(1359840145);

Generate new object id with specific epoch time.

  my $oid = Mango::BSON::ObjectID->new;
  my $oid = Mango::BSON::ObjectID->new('1a2b3c4e5f60718293a4b5c6');

Construct a new Mango::BSON::ObjectID object.

  my $bytes = $oid->to_bytes;

Object id in binary form.

  my $epoch = $oid->to_epoch;

Extract epoch seconds from object id.

  my $str = $oid->to_string;

Stringify object id.

Mango::BSON::ObjectID overloads the following operators.

  my $bool = !!$oid;

Always true.

  my $str = "$oid";

Alias for "to_string".

Mango, Mojolicious::Guides, <http://mojolicio.us>.

2018-04-14 perl v5.26.1