I have the documents below saved in the mongodb collection. They are sorted by the ascending order. I want to only get one document within the specified time interval. ( I'm using node.js with the node-mongodb driver.) How should I implement it?
{"created_at":"2013-03-19T07:14:05Z"}
{"created_at":"2013-03-19T07:35:40Z"}
{"created_at":"2013-03-19T07:59:52Z"}
{"created_at":"2013-03-19T08:01:32Z"}
{"created_at":"2013-03-19T08:02:40Z"}
{"created_at":"2013-03-19T08:02:56Z"}
{"created_at":"2013-03-19T08:06:24Z"}
{"created_at":"2013-03-19T08:07:08Z"}
{"created_at":"2013-03-19T08:23:27Z"}
{"created_at":"2013-03-19T08:27:44Z"}
{"created_at":"2013-03-19T08:27:58Z"}
{"created_at":"2013-03-19T08:28:04Z"}
{"created_at":"2013-03-19T08:28:08Z"}
{"created_at":"2013-03-19T08:28:23Z"}
For example ,if the time interval is 1 minute, the expected result is as below.
{"created_at":"2013-03-19T07:14:05Z"}
{"created_at":"2013-03-19T07:35:40Z"}
{"created_at":"2013-03-19T07:59:52Z"}
{"created_at":"2013-03-19T08:01:32Z"}
{"created_at":"2013-03-19T08:02:40Z"}
{"created_at":"2013-03-19T08:06:24Z"}
{"created_at":"2013-03-19T08:07:08Z"}
{"created_at":"2013-03-19T08:23:27Z"}
{"created_at":"2013-03-19T08:27:44Z"}
{"created_at":"2013-03-19T08:28:04Z"}
The documents below should not be returned.
{"created_at":"2013-03-19T08:02:56Z"}
{"created_at":"2013-03-19T08:27:58Z"}
{"created_at":"2013-03-19T08:28:08Z"}
{"created_at":"2013-03-19T08:28:23Z"}
Thanks,
Jeffrey