c:\mongodb-2.2.1\bin>bsondump.exe dump\local\oplog.rs.bson
{ "ts" : { "t" : 1353099630000 , "i" : 1 }, "h" : 0, "v" : 2, "op" : "n", "ns" : "", "o" : { "msg" : "initiating set" } }
{ "ts" : { "t" : 1353099716000 , "i" : 1 }, "h" : 6562103115049336849, "v" : 2,"op" : "i", "ns" : "sample.mycoll", "o" : { "_id" : "unique-id-1234", "aaa" : "0000", "bbb" : "1111" } }
{ "ts" : { "t" : 1353099904000 , "i" : 1 }, "h" : -7902296395036453900, "v" : 2, "op" : "u", "ns" : "sample.mycoll", "o2" : { "_id" : "unique-id-1234" }, "o" :{ "$set" : { "aaa" : "1234" }, "$set" : { "bbb" : "7654" } } }
3 objects found
This looks better, but there is still a problem since the "o" subdocument from the update contains multiple keys with the same name, "$set". Is this a valid BSON representation?
If I use a driver to query the oplog, I get an exception, so I don't think is it just a shell display issue. Here is an example with the C# driver:
Unhandled Exception: System.InvalidOperationException: Duplicate element name '$set'.
at MongoDB.Bson.BsonDocument.Add(BsonElement element) in C:\work\rstam\mongo-csharp-driver\Bson\ObjectModel\BsonDocument.cs:line 468
at MongoDB.Bson.BsonDocument.Deserialize(BsonReader bsonReader, Type nominalType, IBsonSerializationOptions options) in C:\work\rstam\mongo-csharp-driver\Bso
n\ObjectModel\BsonDocument.cs:line 783
at MongoDB.Bson.BsonDocument.ReadFrom(BsonReader bsonReader) in C:\work\rstam\mongo-csharp-driver\Bson\ObjectModel\BsonDocument.cs:line 409
at MongoDB.Bson.BsonValue.ReadFrom(BsonReader bsonReader) in C:\work\rstam\mongo-csharp-driver\Bson\ObjectModel\BsonValue.cs:line 1069
at MongoDB.Bson.BsonElement.ReadFrom(BsonReader bsonReader, BsonElement& element) in C:\work\rstam\mongo-csharp-driver\Bson\ObjectModel\BsonElement.cs:line 1
67
at MongoDB.Bson.BsonDocument.Deserialize(BsonReader bsonReader, Type nominalType, IBsonSerializationOptions options) in C:\work\rstam\mongo-csharp-driver\Bso
n\ObjectModel\BsonDocument.cs:line 783
at MongoDB.Bson.Serialization.BsonSerializer.Deserialize(BsonReader bsonReader, Type nominalType, IBsonSerializationOptions options) in C:\work\rstam\mongo-c
sharp-driver\Bson\Serialization\BsonSerializer.cs:line 211
at MongoDB.Driver.Internal.MongoReplyMessage`1.ReadFrom(BsonBuffer buffer, IBsonSerializationOptions serializationOptions) in C:\work\rstam\mongo-csharp-driv
er\Driver\Internal\MongoReplyMessage.cs:line 105
at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings readerSettings, IBsonSerializationOptions serializationOptions)
in C:\work\rstam\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 47
5
at MongoDB.Driver.MongoCursorEnumerator`1.GetReply(MongoConnection connection, MongoRequestMessage message) in C:\work\rstam\mongo-csharp-driver\Driver\Core\
MongoCursorEnumerator.cs:line 296
at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst() in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 251
at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext() in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 141
at OplogTest.Program.Main(String[] args) in C:\src\Samples\OplogTest\OplogTest\Program.cs:line 18