3

I'm using ReactiveMongo without the Play fremework.

I'm trying to write the equivalent of the following simple MongoDB query :

db.oplog.rs.find({"o.TimeCreated":{"$gt": ISODate("2014-09-30T10:00:00.000Z")}})

I've tried things like :

val query = BSONDocument(
        "o.TimeCreated" -> BSONDocument("$gt" -> BSONDateTime(ts))) // ts is the timestamp corresponding to the date "2014-09-30T10:00:00.000Z"

hoping that the "$gt" operator would work for comparing two BSONDateTime objects, assuming the value of "o.TimeCreated" would internally be represented as a BSONDateTime object.

But I can't seem to figure out how to make the query work (no data is returned).

Any suggestions ? Thanks !

M. A. Kishawy
  • 5,001
  • 11
  • 47
  • 72
user297112
  • 99
  • 1
  • 4

1 Answers1

0

I can suggest a few options for you to try:

  • You might want to try BSONTimestamp instead of BSONDateTime in your query
  • Do the documents in oplog.rs collection have a top level object named "o.TimeCreated"?
  • Is there an object in the collection that can satisfy the query with the timestamp you've using?
Reid Spencer
  • 2,776
  • 28
  • 37