Overview

Represents an error that occurred during a (potentially paginated) insertMany operation on a Table.

Contains the inserted primary keys of the documents that were successfully inserted, as well as the cumulative errors that occurred during the operation.

If the operation was ordered, the insertedIds will be in the same order as the documents that were attempted to be inserted.

Example

try {
await table.insertMany([
{ id: 'id1', desc: 'An innocent little document' },
{ id: 'id2', desc: 'Another little document minding its own business' },
{ id: 'id2', desc: 'A mean document commiting _identity theft' },
{ id: 'id3', desc: 'A document that will never see the light of day-tabase' },
], { ordered: true });
} catch (e) {
if (e instanceof TableInsertManyError) {
console.log(e.message); // "Document already exists with the given _id"
console.log(e.insertedIds()); // [{ id: 'id1' }, { id: 'id2' }]
console.log(e.errors()); // [DataAPIResponseError(...)]
}
}

Collections vs Tables

There is a sister CollectionInsertManyError class that is used for insertMany operations on collections. It's identical in structure, but uses the appropriate SomeId type for the IDs.

See

  • Table.insertMany
  • CollectionInsertManyError

Hierarchy (view full)

Constructors

Properties

message: string
name: string = 'TableInsertManyError'

The name of the error. This is always 'InsertManyError'.

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