0
0
MongoDBquery~10 mins

Capped collections for fixed-size data in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a capped collection named 'logs' with a maximum size of 1MB.

MongoDB
db.createCollection('logs', { [1]: true, size: 1048576 })
Drag options to blanks, or click blank then click option'
Acapped
BexpireAfterSeconds
CmaxDocuments
DautoIndexId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'autoIndexId' instead of 'capped'.
Confusing 'maxDocuments' with 'capped'.
Using 'expireAfterSeconds' which is for TTL collections.
2fill in blank
medium

Complete the code to create a capped collection with a maximum of 1000 documents.

MongoDB
db.createCollection('events', { capped: true, size: 5242880, [1]: 1000 })
Drag options to blanks, or click blank then click option'
Alimit
BmaxDocuments
Cmax
DmaxSize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'max' which is not a valid option.
Using 'limit' which is not recognized in this context.
Confusing 'maxSize' with document count limit.
3fill in blank
hard

Fix the error in the command to create a capped collection named 'cache' with size 2MB.

MongoDB
db.createCollection('cache', { capped: [1], size: 2097152 })
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
C'true'
D'false'
Attempts:
3 left
💡 Hint
Common Mistakes
Using string 'true' instead of boolean true.
Setting capped to false which disables capped collection.
Using quotes around boolean values.
4fill in blank
hard

Fill both blanks to create a capped collection named 'messages' with size 5MB and max 5000 documents.

MongoDB
db.createCollection('messages', { [1]: true, size: [2], maxDocuments: 5000 })
Drag options to blanks, or click blank then click option'
Acapped
BmaxSize
C5242880
DmaxDocs
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'maxSize' instead of 'size'.
Using 'maxDocs' which is not a valid option.
Setting capped to false.
5fill in blank
hard

Fill all three blanks to create a capped collection named 'audit' with size 10MB, max 10000 documents, and enable autoIndexId.

MongoDB
db.createCollection('audit', { [1]: true, size: [2], [3]: true })
Drag options to blanks, or click blank then click option'
Acapped
B10485760
CautoIndexId
DmaxDocuments
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'maxDocuments' instead of 'autoIndexId' for the third blank.
Setting size to an incorrect byte value.
Not enabling capped collection.