Mango:...bjectID(3pm)
π Mango::BSON::ObjectID β Object ID type π
okay bestie, so this is Mango::BSON::ObjectID, straight out of the User Contributed Perl Documentation collection (3pm section, iykyk). It's the lil container for the BSON object id type that Mango::BSON uses. That's the whole vibe. Let's get into it. π¦
β¨ SYNOPSIS β¨
use Mango::BSON::ObjectID;
my $oid = Mango::BSON::ObjectID->new('1a2b3c4e5f60718293a4b5c6');
say $oid->to_epoch;
literally that's it, that's the whole flex. π
πΈ DESCRIPTION πΈ
Mango::BSON::ObjectID is a container for the BSON object id type used by Mango::BSON. no cap, that's the entire job description, and it does it beautifully. π
π METHODS π
Mango::BSON::ObjectID inherits all methods from Mojo::Base (yes, it's got family money π
) and implements the following new ones.
from_epoch
my $oid = $oid->from_epoch(1359840145);
Generate a new object id with a specific epoch time. you hand it a timestamp, it hands you a fresh oid. iconic. β¨
new
my $oid = Mango::BSON::ObjectID->new;
my $oid = Mango::BSON::ObjectID->new('1a2b3c4e5f60718293a4b5c6');
Construct a brand new Mango::BSON::ObjectID object. call it with nothing and it does its own thing, or pass it a string and it uses that. main character energy either way. π
to_bytes
my $bytes = $oid->to_bytes;
Gives you the object id in binary form. spooky little byte blob, but make it useful. π₯
to_epoch
my $epoch = $oid->to_epoch;
Extract the epoch seconds from the object id. time travel but make it one function call. β
to_string
my $str = $oid->to_string;
Stringify the object id. that's the one you want when you need it to look normal. π
π OPERATORS π
Mango::BSON::ObjectID overloads the following operators, so it can do cute tricks when you use it like a regular Perl value.
bool
my $bool = !!$oid;
Always true. always. it's giving unshakeable confidence, and honestly? we love that for it. π
stringify
my $str = "$oid";
Alias for to_string. same energy, shorter syntax. π
π SEE ALSO π
- Mango
- Mojolicious::Guides
- <http://mojolicio.us>
and that's the whole page, bestie!! π«Ά this gorgeous lil doc is perl v5.30.3, dated 2020-06-05, and it lives in the Mango:...bjectID(3pm) section of the User Contributed Perl Documentation. go forth and slay your object ids. π β¨πΈ
π¦ where this page comes from
- debian bookworm: libmango-perl 1.30-2 Β· Artistic-2.0
- debian trixie: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu jammy: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu noble: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu resolute: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu stonking: libmango-perl 1.30-2 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms