Class TooManyDocumentsToCountError

Caused by a countDocuments operation that failed because the resulting number of documents exceeded either the upper bound set by the caller, or the hard limit imposed by the Data API.

Example

await collections.insertMany('<100_length_array>');

try {
  await collections.countDocuments({}, 50);
} catch (e) {
  if (e instanceof TooManyDocumentsToCountError) {
  console.log(e.limit); // 50
  console.log(e.hitServerLimit); // false
  }
}

Field

limit - The limit that was set by the caller

Field

hitServerLimit - Whether the server-imposed limit was hit

Hierarchy (view full)

Constructors

Properties

hitServerLimit: boolean

Specifies if the server-imposed limit was hit. If this is true, the limit field will contain the server's limit; otherwise it will contain the caller's limit.

limit: number

The limit that was specified by the caller, or the server-imposed limit if the caller's limit was too high.

message: string
name: string
stack?: string
prepareStackTrace?: ((err, stackTraces) => any)

Optional override for formatting stack traces

Type declaration

    • (err, stackTraces): any
    • Parameters

      • err: Error
      • stackTraces: CallSite[]

      Returns any

stackTraceLimit: number

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • Optional constructorOpt: Function

    Returns void