I have this collection
[
{
"_id" : "q8xnGZui5k5po2ZZE",
"suitId" : "QEDMcyEy9pDP5NQQP",
"createdAt" : ISODate("2016-05-06T15:01:16.838Z")
},
{
"_id" : "XQTTw6eh2XXLgZyBG",
"suitId" : "QEDMcyEy9pDP5NQQP",
"createdAt" : ISODate("2016-05-18T12:04:12.454Z")
},
{
"_id" : "fvxrvbYvMDdPg7Hir",
"suitId" : "QEDMcyEy9pDP5NQQP",
"createdAt" : ISODate("2016-05-18T12:04:49.449Z")
},
{
"_id" : "hQXraNmBePwLM9iFZ",
"suitId" : "QEDMcyEy9pDP5NQQP",
"createdAt" : ISODate("2016-05-18T12:04:54.473Z")
},
{
"_id" : "qm8fP3PWcT6gnQZos",
"suitId" : "tckfv4Ae4ywkANh93",
"createdAt" : ISODate("2016-05-18T12:05:10.235Z")
},
{
"_id" : "LMpZFBR5BFdc9ePem",
"suitId" : "tckfv4Ae4ywkANh93",
"createdAt" : ISODate("2016-05-18T12:05:14.465Z")
},
{
"_id" : "wawJfEA6n3TmzS2Mz",
"suitId" : "tckfv4Ae4ywkANh93",
"createdAt" : ISODate("2016-05-18T12:05:18.945Z")
}
]
I need to retrieve the documents belongs to suitId that has createdAt date equals today and the document before it and the document after it. to be like this
[
{suitId: ..., documents: {createdAt: date before today, createdAt: today, createdAt: date after today}},
{suitId: ..., documents: {createdAt: date before today, createdAt: today, createdAt: date after today}},
{suitId: ..., documents: {createdAt: date before today, createdAt: today, createdAt: date after today}},
]