Complete the code to enable sharding on the database named 'sales'.
sh.enableSharding('[1]')
To enable sharding on a database, you use sh.enableSharding() with the database name. Here, 'sales' is the correct database.
Complete the code to shard the collection 'orders' in the 'sales' database using a hashed shard key on the field 'orderId'.
sh.shardCollection('sales.orders', { [1]: 'hashed' })
The shard key field is 'orderId' and it must be specified as the key with the value 'hashed' to use hash-based sharding.
Fix the error in the code to shard the collection 'products' in the 'inventory' database using a hashed shard key on 'productId'.
sh.shardCollection('inventory.products', { [1]: 'hashed' })
The shard key must match the exact field name used in the documents. Here, 'productId' is the correct field name.
Fill both blanks to create a hashed shard key on the 'customerId' field for the 'clients' collection in the 'crm' database.
sh.shardCollection('[1].clients', { [2]: 'hashed' })
The database name is 'crm' and the shard key field is 'customerId'. Both must be correctly placed in the command.
Fill all three blanks to enable sharding on the 'analytics' database, then shard the 'events' collection using a hashed shard key on 'eventId'.
sh.enableSharding('[1]'); sh.shardCollection('[2].[3]', { eventId: 'hashed' })
First, enable sharding on the 'analytics' database. Then shard the 'events' collection in the same database using 'eventId' as the hashed shard key.