1

I am using objmongodb as a tool to communicate with my work's mongodb.

i need to create a query for all docs with a field pickup.recommended equaling todays date.

I'v tried using:

    [predicate keyPath:@"pickup.recommended" matches:[NSDate date]];

as well as

    [predicate keyPath:@"pickup.recommended" matches:@"2014-02-20"];

But all queries return zero results with that added predicate to a MongoFindRequest. And the query was working before i added that statement.

paulmelnikow
  • 16,895
  • 8
  • 63
  • 114
Rohan Panchal
  • 1,211
  • 1
  • 11
  • 28
  • Have you tried widening the window of your search, e.g. from midnight one day to midnight the next? Or overriding the times to noon or midnight on all your dates, so each day actually is equivalent? `[NSDate date]` returns the current time, which won't be the same as `[NSDate date]` a few minutes or seconds ago. – paulmelnikow Feb 21 '14 at 03:54
  • In BSON/Mongo, dates resolve to the nearest millisecond. ObjCMongoDB serializes `NSDate` objects to BSON's datetime. – paulmelnikow Feb 21 '14 at 03:55

1 Answers1

1

To debug this I would suggest running mongod with the -v flag. That will cause it to log all queries, and from that you will likely be able to more easily see why the query is not returning the results you expect.

Bruce Lucas
  • 949
  • 5
  • 5