Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 10 additions & 0 deletions test/types/mongodb.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import type { FindCursor } from '../../src/cursor/find_cursor';
import type { Document } from 'bson';
import { Db } from '../../src';
import { Topology } from '../../src/sdam/topology';
import type { ClientSession } from '../../src/sessions';
import { ReadConcern, ReadConcernLevel } from '../../src/read_concern';
import * as MongoDBDriver from '../../src';

// We wish to keep these APIs but continue to ensure they are marked as deprecated.
Expand Down Expand Up @@ -38,6 +40,14 @@ const composedMap = mappedAgg.map<string>(x => x.toString());
expectType<AggregationCursor<string>>(composedMap);
expectType<string | null>(await composedMap.next());
expectType<string[]>(await composedMap.toArray());
expectType<ClientSession>(
client.startSession({ defaultTransactionOptions: { readConcern: { level: 'snapshot' } } })
);
expectType<ClientSession>(
client.startSession({
defaultTransactionOptions: { readConcern: new ReadConcern(ReadConcernLevel.local) }
})
);

const builtCursor = coll.aggregate();
// should allow string values for the out helper
Expand Down