Skip to content

Instantly share code, notes, and snippets.

@danared
Created April 2, 2015 21:45
Show Gist options
  • Save danared/2a7272eb53150f52143f to your computer and use it in GitHub Desktop.
Save danared/2a7272eb53150f52143f to your computer and use it in GitHub Desktop.
shard01:PRIMARY> c = db.oplog.rs.find( { fromMigrate : { $exists : false } } ).addOption( DBQuery.Option.tailable ).addOption(DBQuery.Option.awaitData)
{ "ts" : Timestamp(1422998530, 1), "h" : NumberLong(0), "v" : 2, "op" : "n", "ns" : "", "o" : { "msg" : "initiating set" } }
{ "ts" : Timestamp(1422998574, 1), "h" : NumberLong("-6781014703318499311"), "v" : 2, "op" : "i", "ns" : "test.mycollection", "o" : { "_id" : 1, "data" : "hello" } }
{ "ts" : Timestamp(1422998579, 1), "h" : NumberLong("-217362260421471244"), "v" : 2, "op" : "i", "ns" : "test.mycollection", "o" : { "_id" : 3, "data" : "hello" } }
{ "ts" : Timestamp(1422998584, 1), "h" : NumberLong("7215322058367374253"), "v" : 2, "op" : "i", "ns" : "test.mycollection", "o" : { "_id" : 5, "data" : "hello" } }
shard01:PRIMARY> c.hasNext()
true
shard01:PRIMARY> c.next()
{
"ts" : Timestamp(1423049506, 1),
"h" : NumberLong("5775895302295493166"),
"v" : 2,
"op" : "i",
"ns" : "test.mycollection",
"o" : {
"_id" : 12,
"data" : "hello"
}
}
shard01:PRIMARY> c.hasNext()
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment