Skip to content

Commit 3f9c0f5

Browse files
mbroadstdaprahamian
authored andcommitted
refactor: support transaction concerns in aggregation operation
1 parent 00ec40a commit 3f9c0f5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/operations/aggregate_operation.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT = 8;
1212

1313
class AggregateOperation extends CommandOperationV2 {
1414
constructor(parent, pipeline, options) {
15+
// ensure we receive an unchanged raw response from the server (for cursor logic)
16+
options.full = true;
1517
super(parent, options);
1618

1719
this.target =
@@ -41,9 +43,14 @@ class AggregateOperation extends CommandOperationV2 {
4143
execute(server, callback) {
4244
const options = this.options;
4345
const serverWireVersion = maxWireVersion(server);
46+
const inTransaction = this.session && this.session.inTransaction();
4447

4548
const command = { aggregate: this.target, pipeline: this.pipeline };
46-
if (!this.hasWriteStage || serverWireVersion >= MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT) {
49+
50+
if (
51+
(!this.hasWriteStage || serverWireVersion >= MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT) &&
52+
!inTransaction
53+
) {
4754
Object.assign(command, { readConcern: this.readConcern });
4855
}
4956

0 commit comments

Comments
 (0)