jeudi 16 juillet 2015

Date range queries mongodb

I've two collections one is random and other one is 'msg'

In message I've a document like

{ "message": "sssss", postedAt: Fri Jul 17 2015 09:03:43 GMT+0530 (IST) }

For random collection, there is a script which generates random number every minute

like

 { "randomStr": "sss", postedAt: Fri Jul 17 2015 09:03:43 GMT+0530 (IST) }
 { "randomStr": "xxx", postedAt: Fri Jul 17 2015 09:04:43 GMT+0530 (IST) }
 { "randomStr": "yyy", postedAt: Fri Jul 17 2015 09:05:43 GMT+0530 (IST) }

Notice the change in timings, for every mintute there is a new record.

Now, my issue is

when I query for message collection, I'll get one record.

Lets's say this

{ "message": "sssss", postedAt: Fri Jul 17 2015 09:03:13 GMT+0530 (IST) }

now I want to get the record from random collection which posts at exact minute

this message is posted at 09:03, I want to get the record from random collection which postedat exactly same time 09:03.

How to do that? Any help appreciated. Thx.




Aucun commentaire:

Enregistrer un commentaire