Class: Binary

Binary

new Binary(buffer, subType){Binary}

A class representation of the BSON Binary type.

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.
Name Type Description
buffer Buffer

a buffer object containing the binary data.

subType Number optional

the option binary type.

Members

staticBinary.SUBTYPE_BYTE_ARRAY

Byte Array BSON type

staticBinary.SUBTYPE_DEFAULT

Default BSON type

staticBinary.SUBTYPE_FUNCTION

Function BSON type

staticBinary.SUBTYPE_MD5

MD5 BSON type

staticBinary.SUBTYPE_USER_DEFINED

User BSON type

staticBinary.SUBTYPE_UUID

UUID BSON type

staticBinary.SUBTYPE_UUID_OLD

OLD UUID BSON type

Methods

Length.

Returns:
length of the binary.

Updates this binary with byte_value.

Name Type Description
byte_value string

a single byte we wish to write.

read(position, length){Buffer}

Reads length bytes starting at position.

Name Type Description
position number

read from the given position in the Binary.

length number

the number of bytes to read.

Returns the value of this binary as a string.

write(string, offset){null}

Writes a buffer or string to the binary.

Name Type Description
string Buffer | string

a string or buffer to be written to the Binary BSON object.

offset number

specify the binary of where to write the content.

comments powered by Disqus