Complete the code to create a sharded collection with a shard key on the 'userId' field.
sh.shardCollection("mydb.users", [1])
The shard key must be specified as a document with the field and the index type. Here, 'userId' with ascending order (1) is a common shard key choice.
Complete the code to shard the 'orders' collection using a hashed shard key on the 'orderId' field.
sh.shardCollection("shop.orders", [1])
Using a hashed shard key on 'orderId' helps distribute data evenly across shards.
Fix the error in the shard key specification to shard the 'products' collection on the 'category' field.
sh.shardCollection("store.products", [1])
The shard key must be a document with the field name and index type as a number (1 for ascending).
Fill both blanks to create a shard key on 'region' with ascending order and enable sharding on the database.
[1] sh.shardCollection("mydb.customers", [2])
First, enable sharding on the database, then shard the collection with the shard key document.
Fill all three blanks to shard the 'logs' collection on 'timestamp' ascending, after enabling sharding on 'analytics' database.
sh.enableSharding([1]) sh.shardCollection([2], [3])
Enable sharding on the 'analytics' database, then shard the 'analytics.logs' collection with 'timestamp' as the shard key ascending.