File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { ReadPreference } from './read_preference' ;
2
2
import { MongoRuntimeError , MongoTransactionError } from './error' ;
3
- import { ReadConcern } from './read_concern' ;
3
+ import { ReadConcern , ReadConcernLike } from './read_concern' ;
4
4
import { WriteConcern } from './write_concern' ;
5
5
import type { Server } from './sdam/server' ;
6
6
import type { CommandOperationOptions } from './operations/command' ;
@@ -63,7 +63,7 @@ const COMMITTED_STATES: Set<TxnState> = new Set([
63
63
export interface TransactionOptions extends CommandOperationOptions {
64
64
// TODO(NODE-3344): These options use the proper class forms of these settings, it should accept the basic enum values too
65
65
/** A default read concern for commands in this transaction */
66
- readConcern ?: ReadConcern ;
66
+ readConcern ?: ReadConcernLike ;
67
67
/** A default writeConcern for commands in this transaction */
68
68
writeConcern ?: WriteConcern ;
69
69
/** A default read preference for commands in this transaction */
Original file line number Diff line number Diff line change
1
+ import { expectType , expectError } from 'tsd' ;
2
+ import { MongoClient } from '../../src/mongo_client' ;
3
+ import { ReadConcern , ReadConcernLevel } from '../../src/read_concern' ;
4
+ import type { ClientSession } from '../../src/sessions' ;
5
+
6
+ // test mapped cursor types
7
+ const client = new MongoClient ( '' ) ;
8
+ // should allow ReadConcern or ReadConcernLike as readConcern in defaultTransactionOptions
9
+ expectType < ClientSession > (
10
+ client . startSession ( { defaultTransactionOptions : { readConcern : { level : 'snapshot' } } } )
11
+ ) ;
12
+ expectType < ClientSession > (
13
+ client . startSession ( {
14
+ defaultTransactionOptions : { readConcern : new ReadConcern ( ReadConcernLevel . local ) }
15
+ } )
16
+ ) ;
17
+ expectError ( client . startSession ( { defaultTransactionOptions : { readConcern : 1 } } ) ) ;
You can’t perform that action at this time.
0 commit comments