Skip to content

Instantly share code, notes, and snippets.

@kgorman
Last active December 13, 2015 17:19
Show Gist options
  • Save kgorman/4946608 to your computer and use it in GitHub Desktop.
Save kgorman/4946608 to your computer and use it in GitHub Desktop.
MongoM:PRIMARY> db.system.profile.findOne()
{
"ts" : ISODate("2013-02-13T17:23:58.809Z"),
"op" : "insert",
"ns" : "test.foot",
"keyUpdates" : 0,
"numYield" : 0,
"millis" : 0,
"client" : "127.0.0.1",
"user" : ""
}
MongoM:PRIMARY> x = new ISODate("2013-02-13T17:23:58.809Z");
ISODate("2013-02-13T17:23:58.809Z")
MongoM:PRIMARY> db.system.profile.find({"ts":x});
MongoM:PRIMARY> y = db.system.profile.findOne()
{
"ts" : ISODate("2013-02-13T17:23:58.812Z"),
....
}
MongoM:PRIMARY> x = new ISODate("2013-02-13T17:23:58.812Z")
ISODate("2013-02-13T17:23:58.812Z")
MongoM:PRIMARY> x
ISODate("2013-02-13T17:23:58.812Z")
MongoM:PRIMARY> y['ts']
ISODate("2013-02-13T17:23:58.812Z")
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY> if (x != y['ts']){ printjson("nope");}
"nope"
--- now try with regular collections:
MongoM:PRIMARY> db.kgtest2.save(y);
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY> db.kgtest2.find()
{ "_id" : ObjectId("511bdeab05eae4a0c1306d21"), "ts" : ISODate("2013-02-13T17:23:58.812Z"), "op" : "insert", "ns" : "test.foot", "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(0), "w" : NumberLong(54) }, "timeAcquiringMicros" : { "r" : NumberLong(0), "w" : NumberLong(4) } }, "millis" : 0, "client" : "127.0.0.1", "user" : "" }
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY> x=db.kgtest2.findOne()
{
"_id" : ObjectId("511bdeab05eae4a0c1306d21"),
"ts" : ISODate("2013-02-13T17:23:58.812Z"),
"op" : "insert",
"ns" : "test.foot",
"keyUpdates" : 0,
"numYield" : 0,
"lockStats" : {
"timeLockedMicros" : {
"r" : NumberLong(0),
"w" : NumberLong(54)
},
"timeAcquiringMicros" : {
"r" : NumberLong(0),
"w" : NumberLong(4)
}
},
"millis" : 0,
"client" : "127.0.0.1",
"user" : ""
}
MongoM:PRIMARY> z = x['ts']
ISODate("2013-02-13T17:23:58.812Z")
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY>
MongoM:PRIMARY> db.kgtest2.find({"ts":z});
{ "_id" : ObjectId("511bdeab05eae4a0c1306d21"), "ts" : ISODate("2013-02-13T17:23:58.812Z"), "op" : "insert", "ns" : "test.foot", "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(0), "w" : NumberLong(54) }, "timeAcquiringMicros" : { "r" : NumberLong(0), "w" : NumberLong(4) } }, "millis" : 0, "client" : "127.0.0.1", "user" : "" }
MongoM:PRIMARY>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment