**Hello,
I have a collection and in that collection I want to get the accountID and it’s count of documents which are inserted in last 30 days. The date column is insertedDate.
For Example there is a accountID = 01 and it have 8 document from which 3 from more then 30 days of timeperiod and 5 are in 30 days so it show like that
{
accountID:01,
totalCount:5
}
there is another document and from last 30 days only 4 documents were inserted so it’s output should be
{
accountID:02
totalCount:4
}
here is the sample document
{
"accountID" : "01",
"insertedDate" : ISODate("2020-12-23T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "01",
"insertedDate" : ISODate("2020-12-22T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "01",
"insertedDate" : ISODate("2020-12-21T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "01",
"insertedDate" : ISODate("2020-12-20T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "01",
"insertedDate" : ISODate("2020-12-19T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "01",
"insertedDate" : ISODate("2020-12-18T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "01",
"insertedDate" : ISODate("2020-12-17T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "01",
"insertedDate" : ISODate("2020-12-16T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "02",
"insertedDate" : ISODate("2020-11-19T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "02",
"insertedDate" : ISODate("2020-11-18T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "02",
"insertedDate" : ISODate("2020-11-10T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "02",
"insertedDate" : ISODate("2020-11-02T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
{
"accountID" : "02",
"insertedDate" : ISODate("2020-07-19T00:00:00Z"),
"remarks" : "One",
"typeKey" : "A",
}
Note that the Date field is insertedDate.
Thanks in advance.