Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace BSON

Index

Type aliases

BSONType: typeof BSON.BSONType[keyof typeof BSON.BSONType]
BinarySequence: Uint8Array | number[]
CalculateObjectSizeOptions: Pick<SerializeOptions, "serializeFunctions" | "ignoreUndefined">
EJSONOptions: { legacy?: boolean; relaxed?: boolean; useBigInt64?: boolean }

Type declaration

  • Optional legacy?: boolean

    Output using the Extended JSON v1 spec

    defaultvalue

    false

  • Optional relaxed?: boolean

    Enable Extended JSON's relaxed mode, which attempts to return native JS types where possible, rather than BSON types

    defaultvalue

    false

  • Optional useBigInt64?: boolean

    Enable native bigint support

    defaultvalue

    false

LongWithoutOverrides: new (low: unknown, high?: number | boolean, unsigned?: boolean) => { [ P in Exclude<keyof Long, TimestampOverrides>]: Long[P] }

Type declaration

    • Parameters

      • low: unknown
      • Optional high: number | boolean
      • Optional unsigned: boolean

      Returns { [ P in Exclude<keyof Long, TimestampOverrides>]: Long[P] }

TimestampOverrides: "_bsontype" | "toExtendedJSON" | "fromExtendedJSON" | "inspect"
UUIDExtended: { $uuid: string }

Type declaration

  • $uuid: string

Variables

BSONType: Readonly<{ array: 4; binData: 5; bool: 8; date: 9; dbPointer: 12; decimal: 19; double: 1; int: 16; javascript: 13; javascriptWithScope: 15; long: 18; maxKey: 127; minKey: -1; null: 10; object: 3; objectId: 7; regex: 11; string: 2; symbol: 14; timestamp: 17; undefined: 6 }>
EJSON: { deserialize: typeof EJSONdeserialize; parse: typeof parse; serialize: typeof EJSONserialize; stringify: typeof stringify }

Type declaration

  • deserialize: typeof EJSONdeserialize
  • parse: typeof parse
  • serialize: typeof EJSONserialize
  • stringify: typeof stringify
LongWithoutOverridesClass: LongWithoutOverrides

Functions

  • Calculate the bson size for a passed in Javascript object.

    Parameters

    Returns number

    size of BSON object in bytes

  • Deserialize data as BSON.

    Parameters

    • buffer: Uint8Array

      the buffer containing the serialized set of BSON documents.

    • Optional options: DeserializeOptions

    Returns Document

    returns the deserialized Javascript Object.

  • deserializeStream(data: Uint8Array | ArrayBuffer, startIndex: number, numberOfDocuments: number, documents: Document[], docStartIndex: number, options: DeserializeOptions): number
  • Deserialize stream data as BSON documents.

    Parameters

    • data: Uint8Array | ArrayBuffer

      the buffer containing the serialized set of BSON documents.

    • startIndex: number

      the start index in the data Buffer where the deserialization is to start.

    • numberOfDocuments: number

      number of documents to deserialize.

    • documents: Document[]

      an array where to store the deserialized documents.

    • docStartIndex: number

      the index in the documents array from where to start inserting documents.

    • options: DeserializeOptions

      additional options used for the deserialization.

    Returns number

    next index in the buffer after deserialization x numbers of documents.

  • Serialize a Javascript object.

    Parameters

    Returns Uint8Array

    Buffer object containing the serialized object.

  • Serialize a Javascript object using a predefined Buffer and index into the buffer, useful when pre-allocating the space for serialization.

    Parameters

    • object: Document

      the Javascript object to serialize.

    • finalBuffer: Uint8Array

      the Buffer you pre-allocated to store the serialized BSON object.

    • Optional options: SerializeOptions

    Returns number

    the index pointing to the last written byte in the buffer.

  • setInternalBufferSize(size: number): void
  • Sets the size of the internal serialization buffer.

    Parameters

    • size: number

      The desired size for the internal serialization buffer in bytes

    Returns void

Generated using TypeDoc