class MongoTransactionUnavailableError
extends Error
Since 0.1.0

Thrown by MongoAdapter.beginTransaction on a deployment without a replica set.

A standalone mongod is a legitimate deployment for an application that never opens a transaction, so the refusal is named and late — it happens at beginTransaction(), never at connect(), where probing would cost a round trip on every boot and refuse a working configuration.

Examples

Example 1

import { MongoTransactionUnavailableError } from '@setu-ts/database-plugin';
try {
  await adapter.beginTransaction();
} catch (err) {
  if (err instanceof MongoTransactionUnavailableError) {
    console.error(err.message);
  }
}

Constructors

MongoTransactionUnavailableError(
message: string,
options?: ErrorOptions
)

Creates the error.

Parameters
message: string

The full diagnostic, safe to log

optional
options: ErrorOptions

Native error options, including an underlying cause

Properties

readonly
name: string

Discriminant for consumers that cannot use instanceof across realms.

Usage

import { MongoTransactionUnavailableError } from "database-plugin/src/index.ts";