I am not sure this is possible to achieve, I just want to be certain.
I have sorted dates records, for example:
{id: 1, date: 2015-08-18T00:00:00Z },
{id: 2, date: 2015-08-18T00:01:00Z },
{id: 3, date: 2015-08-18T00:02:00Z },
{id: 4, date: 2015-08-18T00:03:00Z },
{id: 5, date: 2015-08-18T00:04:00Z },
And I only want to get the records that are separated by at least 2 minutes. record 2 would be invalid, because it is less than 2 minutes before record 1, but record 3 would be valid, so the result would be:
{id: 1, date: 2015-08-18T00:00:00Z },
{id: 3, date: 2015-08-18T00:02:00Z },
{id: 5, date: 2015-08-18T00:04:00Z },
I think the only way is to query them all, and do the filtering programmatically, but i am curious to know if there is an a pure mongoDB solution to this problem.