Skip to main content
Module

x/mongo/mod.ts>Binary

MongoDB driver for Deno
Very Popular
Go to Latest
class Binary
extends BSONValue
Re-export
import { Binary } from "https://deno.land/x/mongo@v0.31.2/mod.ts";

A class representation of the BSON Binary type.

Constructors

new
Binary(buffer?: string | BinarySequence, subType?: number)

Create a new Binary instance.

This constructor can accept a string as its first argument. In this case, this string will be encoded using ISO-8859-1, not using UTF-8. This is almost certainly not what you want. Use new Binary(Buffer.from(string)) instead to convert the string to a Buffer using UTF-8 first.

Properties

readonly
_bsontype: "Binary"
buffer: Uint8Array
position: number
sub_type: number

Methods

inspect(): string
length(): number

the length of the binary sequence

put(byteValue:
| string
| number
| Uint8Array
| number[]
): void

Updates this binary with byte_value.

read(position: number, length: number): BinarySequence

Reads length bytes starting at position.

toJSON(): string
toString(encoding?:
| "hex"
| "base64"
| "utf8"
| "utf-8"
): string
value(asRaw?: boolean): string | BinarySequence

Returns the value of this binary as a string.

write(sequence: string | BinarySequence, offset: number): void

Writes a buffer or string to the binary.

Static Properties

readonly
BUFFER_SIZE: number

Initial buffer default size

readonly
SUBTYPE_BYTE_ARRAY: number

Byte Array BSON type

readonly
SUBTYPE_COLUMN: number

Column BSON type

readonly
SUBTYPE_DEFAULT: number

Default BSON type

readonly
SUBTYPE_ENCRYPTED: number

Encrypted BSON type

readonly
SUBTYPE_FUNCTION: number

Function BSON type

readonly
SUBTYPE_MD5: number

MD5 BSON type

readonly
SUBTYPE_USER_DEFINED: number

User BSON type

readonly
SUBTYPE_UUID: number

UUID BSON type

readonly
SUBTYPE_UUID_OLD: number

Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID