Counting the document and adding the resultant to another collection

But you have missed couples of thing, how can I get the count of the document of last 30 days( form postedDate field) and then on that bases we have to create a new field in next collection.