.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "MongoDB::BSON::Binary 3pm" .TH MongoDB::BSON::Binary 3pm "2016-09-09" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MongoDB::BSON::Binary \- MongoDB binary type .SH "VERSION" .IX Header "VERSION" version v1.4.5 .SH "SYNOPSIS" .IX Header "SYNOPSIS" Creates an instance of binary data with a specific subtype. .SH "USAGE" .IX Header "USAGE" For example, suppose we wanted to store a profile pic. .PP .Vb 2 \& my $pic = MongoDB::BSON::Binary\->new(data => $pic_bytes); \& $collection\->insert({name => "profile pic", pic => $pic}); .Ve .PP You can also, optionally, specify a subtype: .PP .Vb 3 \& my $pic = MongoDB::BSON::Binary\->new(data => $pic_bytes, \& subtype => MongoDB::BSON::Binary\->SUBTYPE_GENERIC); \& $collection\->insert({name => "profile pic", pic => $pic}); .Ve .SS "Overloading" .IX Subsection "Overloading" MongoDB::BSON::Binary objects have stringification overloaded to return the binary data. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .SS "data" .IX Subsection "data" A string of binary data. .SS "subtype" .IX Subsection "subtype" A subtype. Defaults to \f(CW\*(C`SUBTYPE_GENERIC\*(C'\fR. .SH "SUBTYPES" .IX Header "SUBTYPES" MongoDB allows you to specify the \*(L"flavor\*(R" of binary data that you are storing by providing a subtype. The subtypes are purely cosmetic: the database treats them all the same. .PP There are several subtypes defined in the \s-1BSON\s0 spec: .ie n .IP """SUBTYPE_GENERIC"" (0x00) is the default used by the driver (as of 0.46)." 4 .el .IP "\f(CWSUBTYPE_GENERIC\fR (0x00) is the default used by the driver (as of 0.46)." 4 .IX Item "SUBTYPE_GENERIC (0x00) is the default used by the driver (as of 0.46)." .PD 0 .ie n .IP """SUBTYPE_FUNCTION"" (0x01) is for compiled byte code." 4 .el .IP "\f(CWSUBTYPE_FUNCTION\fR (0x01) is for compiled byte code." 4 .IX Item "SUBTYPE_FUNCTION (0x01) is for compiled byte code." .ie n .IP """SUBTYPE_GENERIC_DEPRECATED"" (0x02) is deprecated. It was used by the driver prior to version 0.46, but this subtype wastes 4 bytes of space so ""SUBTYPE_GENERIC"" is preferred. This is the only type that is parsed differently based on type." 4 .el .IP "\f(CWSUBTYPE_GENERIC_DEPRECATED\fR (0x02) is deprecated. It was used by the driver prior to version 0.46, but this subtype wastes 4 bytes of space so \f(CWSUBTYPE_GENERIC\fR is preferred. This is the only type that is parsed differently based on type." 4 .IX Item "SUBTYPE_GENERIC_DEPRECATED (0x02) is deprecated. It was used by the driver prior to version 0.46, but this subtype wastes 4 bytes of space so SUBTYPE_GENERIC is preferred. This is the only type that is parsed differently based on type." .ie n .IP """SUBTYPE_UUID_DEPRECATED"" (0x03) is deprecated. It is for UUIDs." 4 .el .IP "\f(CWSUBTYPE_UUID_DEPRECATED\fR (0x03) is deprecated. It is for UUIDs." 4 .IX Item "SUBTYPE_UUID_DEPRECATED (0x03) is deprecated. It is for UUIDs." .ie n .IP """SUBTYPE_UUID"" (0x04) is for UUIDs." 4 .el .IP "\f(CWSUBTYPE_UUID\fR (0x04) is for UUIDs." 4 .IX Item "SUBTYPE_UUID (0x04) is for UUIDs." .ie n .IP """SUBTYPE_MD5"" can be (0x05) is for \s-1MD5\s0 hashes." 4 .el .IP "\f(CWSUBTYPE_MD5\fR can be (0x05) is for \s-1MD5\s0 hashes." 4 .IX Item "SUBTYPE_MD5 can be (0x05) is for MD5 hashes." .ie n .IP """SUBTYPE_USER_DEFINED"" (0x80) is for user-defined binary types." 4 .el .IP "\f(CWSUBTYPE_USER_DEFINED\fR (0x80) is for user-defined binary types." 4 .IX Item "SUBTYPE_USER_DEFINED (0x80) is for user-defined binary types." .PD .ie n .SS "Why is ""SUBTYPE_GENERIC_DEPRECATED"" deprecated?" .el .SS "Why is \f(CWSUBTYPE_GENERIC_DEPRECATED\fP deprecated?" .IX Subsection "Why is SUBTYPE_GENERIC_DEPRECATED deprecated?" Binary data is stored with the length of the binary data, the subtype, and the actually data. \f(CW\*(C`SUBTYPE_GENERIC DEPRECATED\*(C'\fR stores the length of the data a second time, which just wastes four bytes. .PP If you have been using \f(CW\*(C`SUBTYPE_GENERIC_DEPRECATED\*(C'\fR for binary data, moving to \&\f(CW\*(C`SUBTYPE_GENERIC\*(C'\fR should be painless: just use the driver normally and all new/resaved data will be stored as \f(CW\*(C`SUBTYPE_GENERIC\*(C'\fR. .PP It gets a little trickier if you've been querying by binary data fields: \&\f(CW\*(C`SUBTYPE_GENERIC\*(C'\fR won't match \f(CW\*(C`SUBTYPE_GENERIC_DEPRECATED\*(C'\fR, even if the data itself is the same. .ie n .SS "Why is ""SUBTYPE_UUID_DEPRECATED"" deprecated?" .el .SS "Why is \f(CWSUBTYPE_UUID_DEPRECATED\fP deprecated?" .IX Subsection "Why is SUBTYPE_UUID_DEPRECATED deprecated?" Other languages were using the \s-1UUID\s0 type to deserialize into their languages' native \s-1UUID\s0 type. They were doing this in different ways, so to standardize, they decided on a deserialization format for everyone to use and changed the subtype for \s-1UUID\s0 to the universal format. .PP This should not affect Perl users at all, as Perl does not deserialize it into any native \s-1UUID\s0 type. .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 David Golden .IP "\(bu" 4 Mike Friedman .IP "\(bu" 4 Kristina Chodorow .IP "\(bu" 4 Florian Ragwitz .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2016 by MongoDB, Inc. .PP This is free software, licensed under: .PP .Vb 1 \& The Apache License, Version 2.0, January 2004 .Ve