- Reference >
mongoShell Methods >- Object Constructors and Methods >
- BinData()
BinData()¶
On this page
Definition¶
Creates a binary data object.
BinData has the following syntax:
-
BinData(<sub_type>, <buffer>)¶ Parameter Type Description sub_typestring The binary type.
Subtype Description 0 Generic binary subtype 1 Function 2 Byte Array 3 OLD UUID 4 UUID 5 MD5 128 User defined bufferstring The buffer object containing binary data, must be a base 64 encoded string value. Returns: A binary data object.
Examples¶
Insert a BinData() Object¶
Use the BinData() constructor to create the bdata variable.
Insert the object into the testbin collection.
Query the testbin collection for the inserted document.
You can see the binary buffer stored in the collection.
Get the Length of BinData() Object¶
Use the BinData() constructor to create the bdata variable.
Use .length() to return the bit length of the object.
The returned value is: