2020-08-13 19:13:40 -04:00
|
|
|
// @tags: [
|
|
|
|
|
// requires_fastcount,
|
2021-04-07 14:53:12 -04:00
|
|
|
// requires_multi_updates,
|
2020-08-13 19:13:40 -04:00
|
|
|
// requires_non_retryable_writes,
|
2025-11-21 12:33:41 -05:00
|
|
|
// # Time series collections do not support indexing array values in measurement fields.
|
|
|
|
|
// exclude_from_timeseries_crud_passthrough,
|
2020-08-13 19:13:40 -04:00
|
|
|
// ]
|
2010-07-01 11:00:53 -04:00
|
|
|
|
2025-02-04 14:03:10 -05:00
|
|
|
const t = db[jsTestName()];
|
2010-07-01 11:00:53 -04:00
|
|
|
t.drop();
|
|
|
|
|
|
2025-08-21 10:17:44 -07:00
|
|
|
assert.commandWorked(t.insert({abc: {visible: true}, testarray: [{foobar_id: 316, visible: true, xxx: 1}]}));
|
|
|
|
|
assert.commandWorked(t.createIndex({"abc.visible": 1, "testarray.visible": 1, "testarray.xxx": 1}));
|
|
|
|
|
assert(t.findOne({"abc.visible": true, testarray: {"$elemMatch": {visible: true, xxx: 1}}}), "A1");
|
|
|
|
|
assert(t.findOne({testarray: {"$elemMatch": {visible: true, xxx: 1}}}), "A2");
|
2010-07-01 11:00:53 -04:00
|
|
|
|
2025-08-21 10:17:44 -07:00
|
|
|
assert.commandWorked(
|
|
|
|
|
t.update({"testarray.foobar_id": 316}, {"$set": {"testarray.$.visible": true, "testarray.$.xxx": 2}}, false, true),
|
|
|
|
|
);
|
2010-07-01 11:00:53 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert(t.findOne(), "B1");
|
2025-08-21 10:17:44 -07:00
|
|
|
assert(t.findOne({testarray: {"$elemMatch": {visible: true, xxx: 2}}}), "B2");
|
|
|
|
|
assert(t.findOne({"abc.visible": true, testarray: {"$elemMatch": {visible: true, xxx: 2}}}), "B3");
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(1, t.find().count(), "B4");
|