jstests/libs/change_stream_rewrite_util.js
// Returns a newly created sharded collection sharded by caller provided shard key.
Returns a newly created sharded collection sharded by caller provided shard key.
Returns a newly created sharded collection sharded by caller provided shard key .
function createShardedCollection(shardingTest, shardKey, dbName, collName, splitAt) {
    const db = shardingTest.s.getDB(dbName);
    assertDropAndRecreateCollection(db, collName);
    const coll = db.getCollection(collName);
    assert.commandWorked(coll.createIndex({[shardKey]: 1}));
    shardingTest.ensurePrimaryShard(dbName, shardingTest.shard0.shardName);
    shardingTest.shardColl(
        collName,
        {[shardKey]: 1} ,
        {[shardKey]: splitAt} ,
        {[shardKey]: splitAt} ,
        dbName,
        true);
    return coll;
}
function createShardedCollection ( shardingTest , shardKey , dbName , collName , splitAt ) { const db = shardingTest . s . getDB ( dbName ) ; assertDropAndRecreateCollection ( db , collName ) ; const coll = db . getCollection ( collName ) ; assert . commandWorked ( coll . createIndex ( { [ shardKey ] : 1 } ) ) ; shardingTest . ensurePrimaryShard ( dbName , shardingTest . shard0 . shardName ) ; shardingTest . shardColl ( collName , { [ shardKey ] : 1 } , { [ shardKey ] : splitAt } , { [ shardKey ] : splitAt } , dbName , true ) ; return coll ; }
Returns a newly created sharded collection sharded by caller provided shard key.
Returns a newly created sharded collection sharded by caller provided shard key .
// Shard the test collection and split it into two chunks: one that contains all {shardKey: <lt // splitAt>} documents and one that contains all {shardKey: <gte splitAt>} documents. /* shard key */ /* split at */ /* move the chunk containing {shardKey: splitAt} to its own shard */