summaryrefslogtreecommitdiff
path: root/jstests/core/aggregation_accepts_write_concern.js
blob: 2c764414a1d7bd2b101d646c97420db2c810801f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
 * Confirms that the aggregate command accepts writeConcern regardless of whether the pipeline
 * writes or is read-only.
 * @tags: [assumes_write_concern_unchanged, does_not_support_stepdowns]
 */
(function() {
"use strict";

const testDB = db.getSiblingDB("aggregation_accepts_write_concern");
assert.commandWorked(testDB.dropDatabase());
const collName = "test";

assert.commandWorked(
    testDB.runCommand({insert: collName, documents: [{_id: 1}], writeConcern: {w: "majority"}}));

// A read-only aggregation accepts writeConcern.
assert.commandWorked(testDB.runCommand({
    aggregate: collName,
    pipeline: [{$match: {_id: 1}}],
    cursor: {},
    writeConcern: {w: "majority"}
}));

// An aggregation pipeline that writes accepts writeConcern.
assert.commandWorked(testDB.runCommand({
    aggregate: collName,
    pipeline: [{$match: {_id: 1}}, {$out: collName + "_out"}],
    cursor: {},
    writeConcern: {w: "majority"}
}));
})();