BSON::Int64(3pm)

πŸ“¦
version 1.12.2 Β· 5 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– BSON::Int64 πŸ’–

okay bestie, so this is the BSON::Int64 page from the User Contributed Perl Documentation, and it's literally the moment you learn how to wrap a big ol' 64-bit integer in a BSON-friendly lil package. slay. let's get into it πŸ¦‹


✨ VERSION ✨

version v1.12.2 β€” that's the vibe. that's the version. periodt. πŸ’…


🌸 SYNOPSIS 🌸

use BSON::Types ':all';

bson_int64( $number );

that's it. that's the whole thing. you import everything from BSON::Types, you call bson_int64 on your number, and you're done. main character energy fr fr. πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the tea: this module gives you a BSON type wrapper for a numeric value that would be represented in BSON as a 64-bit integer. that's its whole job. it's very good at its job. 🫢

but listen β€” if the value won't fit in a 64-bit integer, an error will be thrown. no cap. so don't try to sneak a giant number in there thinking nobody will notice, because somebody (the module) will absolutely notice. πŸ’€

and if you're on a Perl that doesn't have 64-bit integer support? then the value must be a Math::BigInt object. that's not a suggestion, bestie, that's the rule. 🧚


πŸ¦‹ ATTRIBUTES πŸ¦‹

value

a numeric scalar, babe. it will be coerced to an integer β€” so it's getting rounded/trimmed into shape whether it likes it or not. the default is 0. 🌸


⭐ METHODS ⭐

TO_JSON

okay this one's got layers, stay with me:

  • on a 64-bit perl, it returns the value as an integer. simple. clean. iconic. ✨
  • on a 32-bit Perl, it gets returned as a Math::BigInt object β€” and here's the warning, bestie β€” that will fail to serialize unless a TO_JSON method is defined for that object, or in package universal. so like, define your method or it's not gonna work. πŸ™ˆ

and there's a whole extra vibe check: if the BSON_EXTJSON environment variable is true and the BSON_EXTJSON_RELAXED environment variable is false, then it returns a hashref compatible with MongoDB's extended JSON format, which represents it as a document like this:

{"$numberLong" : "223372036854775807"}

(extended JSON spec lives at https://github.com/mongodb/specifications/blob/master/source/extended-json.rst if you wanna go read it, iykyk πŸ’œ)


πŸ’… OVERLOADING πŸ’…

the numification operator, 0+, is overloaded to return the value. the full "minimal set" of overloaded operations is provided (per overload documentation), and fallback overloading is enabled. so it behaves like a number basically everywhere you'd expect. lowkey elegant, highkey obsessed. 😭πŸ”₯


πŸ‘‘ AUTHORS πŸ‘‘

  • David Golden <david@mongodb.com>
  • Stefan G. <minimalist@lavabit.com>

two absolute legends, we stan. 🫢


This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004

free software, free love, free license. periodt. πŸ’–


and that's the whole page, bestie!! this was BSON::Int64 from perl v5.30.3, dated 2020-08-14. go forth and wrap your 64-bit integers responsibly. mwah. πŸŽ€βœ¨

πŸ“¦ where this page comes from