Binary()
Constructor
A class representation of the BSON Binary type.
-
class Binary()
Arguments: |
- buffer (buffer) – a buffer object containing the binary data.
- [subType] (number) – the option binary type.
|
Returns: | grid
|
- Sub types
- BSON.BSON_BINARY_SUBTYPE_DEFAULT, default BSON type.
- BSON.BSON_BINARY_SUBTYPE_FUNCTION, BSON function type.
- BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY, BSON byte array type.
- BSON.BSON_BINARY_SUBTYPE_UUID, BSON uuid type.
- BSON.BSON_BINARY_SUBTYPE_MD5, BSON md5 type.
- BSON.BSON_BINARY_SUBTYPE_USER_DEFINED, BSON user defined type.
Constants
Constant Name |
Value |
Description |
Binary.SUBTYPE_DEFAULT |
0 |
Default BSON type |
Binary.SUBTYPE_FUNCTION |
1 |
Function BSON type |
Binary.SUBTYPE_BYTE_ARRAY |
2 |
Byte Array BSON type |
Binary.SUBTYPE_UUID_OLD |
3 |
OLD UUID BSON type |
Binary.SUBTYPE_UUID |
4 |
UUID BSON type |
Binary.SUBTYPE_MD5 |
5 |
MD5 BSON type |
Binary.SUBTYPE_USER_DEFINED |
128 |
User BSON type |
put
Updates this binary with byte_value.
-
put(byte_value)
Arguments: |
- byte_value (character) – a single byte we wish to write.
|
write
Writes a buffer or string to the binary.
-
write(string, offset)
Arguments: |
- string (buffer) – a string or buffer to be written to the Binary BSON object.
- offset (number) – specify the binary of where to write the content.
|
read
Reads length bytes starting at position.
-
read(position, length)
Arguments: |
- position (number) – read from the given position in the Binary.
- length (number) – the number of bytes to read.
|
Returns: | buffer
|
value
Returns the value of this binary as a string.
-
value()
-
length
Length.
-
length()
Returns: | number the length of the binary. |