summaryrefslogtreecommitdiff
path: root/jstests/core/timeseries/timeseries_id_index.js
blob: e3bc20d66481d6eff355fb92908742d3e75f1663 (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
/**
 * Verifies that the _id index can be created on a timeseries collection.
 *
 * @tags: [
 *   requires_fcv_52,
 *   does_not_support_stepdowns,
 *   does_not_support_transactions,
 *   requires_getmore,
 * ]
 */
(function() {
"use strict";

const coll = db.timeseries_id_index;
coll.drop();

const timeFieldName = "time";
assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));

const bucketsColl = db.getCollection("system.buckets." + coll.getName());

assert.commandWorked(bucketsColl.createIndex({"_id": 1}));
assert.commandWorked(bucketsColl.createIndex({"_id": 1}, {clustered: true, unique: true}));

// Passing 'clustered' without unique, regardless of the type of clustered collection, is illegal.
assert.commandFailedWithCode(bucketsColl.createIndex({"_id": 1}, {clustered: true}),
                             ErrorCodes.CannotCreateIndex);
})();