What are different letters in MongoDB oplog "op" field means ? I can guess some of the letters meaning but I am not sure.
"n" = ?
"i" = insert , is this correct ?
"u" = update, is this correct ?
"c" = count, is this correct ?
I guess "d"= delete ?
what are other letters are there and what are their meanings ?
From mongohq, these are the values that the op field can contain and their meanings. "i", "u", "d", "c", "db", "n":
This is the “op” field which indicates what operation took place. Its values can be “i” for “insert”, “u” for “update”, and “d” for “delete”. For most oplog tailing applications, you will only be interested in these three values, but there is also a “c” for commands that affect databases at a high level, “db” which apparently announces the presence of a “database”, and “n” for “no-ops”, used for changes in the database or collections which don’t result in a change in the stored data.
Any of these operations will have been applied to a database or a collection so the next field, “ns” tells us the “namespace” for this operation.
http://blog.mongohq.com/the-mongodb-oplog-and-node-js/
> use test
switched to db test
> db.foo.insert({x:1})
> db.foo.update({x:1}, {$set : {y:1}})
> db.foo.update({x:2}, {$set : {y:1}}, true)
> db.foo.remove({x:1})
Now in oplog
> use local
switched to db local
> db.oplog.rs.find()
{ "ts" : { "t" : 1286821527000, "i" : 1 }, "h" : NumberLong(0), "op" : "n", "ns" : "", "o" : { "msg" : "initiating set" } }
{ "ts" : { "t" : 1286821977000, "i" : 1 }, "h" : NumberLong("1722870850266333201"), "op" : "i", "ns" : "test.foo", "o" : { "_id" : ObjectId("4cb35859007cc1f4f9f7f85d"), "x" : 1 } }
{ "ts" : { "t" : 1286821984000, "i" : 1 }, "h" : NumberLong("1633487572904743924"), "op" : "u", "ns" : "test.foo", "o2" : { "_id" : ObjectId("4cb35859007cc1f4f9f7f85d") }, "o" : { "$set" : { "y" : 1 } } }
{ "ts" : { "t" : 1286821993000, "i" : 1 }, "h" : NumberLong("5491114356580488109"), "op" : "i", "ns" : "test.foo", "o" : { "_id" : ObjectId("4cb3586928ce78a2245fbd57"), "x" : 2, "y" : 1 } }
{ "ts" : { "t" : 1286821996000, "i" : 1 }, "h" : NumberLong("243223472855067144"), "op" : "d", "ns" : "test.foo", "b" : true, "o" : { "_id" : ObjectId("4cb35859007cc1f4f9f7f85d") } }
op: the write operation that should be applied to the slave. n indicates a no-op, this is just an informational message.
> i for inserts
> u for updates
> and d for deletes
The o field now contains the document to insert or the criteria to update and remove. Notice that, for the update, there are two o fields (o and o2). o2 give the update criteria and o gives the modifications (equivalent to update()‘s second argument).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With