class Bson.Binary
extends BSONValue
import { Bson } from "https://deno.land/x/mongo@v0.31.2/mod.ts";
const { Binary } = Bson;
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.
Methods
inspect(): string
toJSON(): string
toString(encoding?: ): string
| "hex"
| "base64"
| "utf8"
| "utf-8"
write(sequence: string | BinarySequence, offset: number): void
Writes a buffer or string to the binary.