0
0
MongoDBquery~10 mins

Oplog and replication mechanism 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 query the oplog collection in MongoDB.

MongoDB
db.local.oplog.rs.find([1])
Drag options to blanks, or click blank then click option'
A{ts: 1}
B{op: 'i'}
C{}
D{ns: 'test.collection'}
Attempts:
3 left
💡 Hint
Common Mistakes
Using a filter that restricts results unintentionally.
Leaving the parentheses empty without an object.
2fill in blank
medium

Complete the code to find oplog entries for insert operations only.

MongoDB
db.local.oplog.rs.find({op: [1])
Drag options to blanks, or click blank then click option'
A'c'
B'u'
C'd'
D'i'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'u' or 'd' which filter updates or deletes instead of inserts.
Forgetting to put quotes around the operation code.
3fill in blank
hard

Fix the error in the code to query oplog entries after a specific timestamp.

MongoDB
db.local.oplog.rs.find({ts: {$gt: [1])
Drag options to blanks, or click blank then click option'
ATimestamp(1, 0)
BISODate('2023-01-01')
Cnew Date()
DObjectId()
Attempts:
3 left
💡 Hint
Common Mistakes
Using ISODate or Date which do not match the oplog timestamp type.
Using ObjectId which is unrelated here.
4fill in blank
hard

Fill both blanks to create a query that finds oplog entries for updates on a specific namespace.

MongoDB
db.local.oplog.rs.find({op: [1], ns: [2])
Drag options to blanks, or click blank then click option'
A'u'
B'i'
C'test.collection'
D'admin.system'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'i' instead of 'u' for updates.
Using wrong namespace strings.
5fill in blank
hard

Fill all three blanks to create a query that finds delete oplog entries on 'logs.events' namespace after a given timestamp.

MongoDB
db.local.oplog.rs.find({op: [1], ns: [2], ts: {$gt: [3])
Drag options to blanks, or click blank then click option'
A'd'
B'logs.events'
CTimestamp(1672531200, 1)
D'admin.system'
Attempts:
3 left
💡 Hint
Common Mistakes
Using string dates instead of Timestamp.
Mixing up operation codes.
Incorrect namespace format.