Sorry for the bad title. I didn't know how to word it. So, I have a set of data about states and I cannot figure out how to structure my pipeline to get the specific data. Here is an example of the documents I have in the collection.
{
state: "California",
date: "2010-08-11"
otherData: "Something Else"
}
All documents are formatted in that way. What I want to do is to get one document for each state with the most recent date. I have tried using $group, but I can't figure out how to get the data from just one document. I tried using $match but I then I don't know how to get just one for each state.