Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReadPreference } from './read_preference';
import { MongoRuntimeError, MongoTransactionError } from './error';
import { ReadConcern } from './read_concern';
import { ReadConcern, ReadConcernLike } from './read_concern';
import { WriteConcern } from './write_concern';
import type { Server } from './sdam/server';
import type { CommandOperationOptions } from './operations/command';
Expand Down Expand Up @@ -63,7 +63,7 @@ const COMMITTED_STATES: Set<TxnState> = new Set([
export interface TransactionOptions extends CommandOperationOptions {
// TODO(NODE-3344): These options use the proper class forms of these settings, it should accept the basic enum values too
/** A default read concern for commands in this transaction */
readConcern?: ReadConcern;
readConcern?: ReadConcernLike;
/** A default writeConcern for commands in this transaction */
writeConcern?: WriteConcern;
/** A default read preference for commands in this transaction */
Expand Down
17 changes: 17 additions & 0 deletions test/types/sessions.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { expectType, expectError } from 'tsd';
import { MongoClient } from '../../src/mongo_client';
import { ReadConcern, ReadConcernLevel } from '../../src/read_concern';
import type { ClientSession } from '../../src/sessions';

// test mapped cursor types
const client = new MongoClient('');
// should allow ReadConcern or ReadConcernLike as readConcern in defaultTransactionOptions
expectType<ClientSession>(
client.startSession({ defaultTransactionOptions: { readConcern: { level: 'snapshot' } } })
);
expectType<ClientSession>(
client.startSession({
defaultTransactionOptions: { readConcern: new ReadConcern(ReadConcernLevel.local) }
})
);
expectError(client.startSession({ defaultTransactionOptions: { readConcern: 1 } }));