Ivan Ratnikov > MongoDB-Async-0.45 > MongoDB::Async::BSON



Annotate this POD


New  2
Open  0
View/Report Bugs
Module Version: 0.45   Source   Latest Release: MongoDB-Async-0.702.3


MongoDB::Async::BSON - Encoding and decoding utilities (more to come)



    $MongoDB::Async::BSON::looks_like_number = 1;
    $collection->insert({age => "4"}); # stores 4 as an int

If this is set, the driver will be more aggressive about converting strings into numbers. Anything that Scalar::Util's looks_like_number would approve as a number will be sent to MongoDB as its numeric value.

Defaults to 0 (for backwards compatibility).

If you do not set this, you may be using strings more often than you intend to. See the MongoDB::Async::DataTypes section for more info on the behavior of strings vs. numbers.


    $MongoDB::Async::BSON::char = ":";
    $collection->query({"x" => {":gt" => 4}});

Can be used to set a character other than "$" to use for special operators.

Turn on/off UTF8 flag when return strings

    # turn off utf8 flag on strings
    $MongoDB::Async::BSON::utf8_flag_on = 0;

Default is turn on, that compatible with version before 0.34.

If set to 0, will turn of utf8 flag on string attribute and return on bytes mode, meant same as :


Currently MongoDB return string with utf8 flag, on character mode , some people wish to turn off utf8 flag and return string on byte mode, it maybe help to display "pretty" strings.


If you turn off utf8 flag, the string length will compute as bytes, and is_utf8 will return false.

Return boolean values as booleans instead of integers

    $MongoDB::Async::BSON::use_boolean = 1

By default, booleans are deserialized as integers. If you would like them to be deserialized as "true" in boolean and "false" in boolean, set $MongoDB::Async::BSON::use_boolean to 1.

syntax highlighting: