In couchDB, I have a set of items like the following (simplified for example's sake):
{_id: 1, date: "Jul 1", user: "user1"}
{_id: 2, date: "Jul 2", user: "user1"}
{_id: 3, date: "Jul 3", user: "user2"}
...etc...
I'd like to get a list of "most recent activity", sorted by date, with no duplicate user _ids. I can create a view with results like so:
{key: "July 3", _id: 3, user: "user2"}
{key: "July 2", _id: 2, user: "user1"}
{key: "July 1", _id: 1, user: "user1"}
but this contains duplicate entries for the same user. Or I can create a view that maps {key: user, value: date} and reduces to
{key: "user1", mostRecentDate: "July 2"}
{key: "user2", mostRecentDate: "July 3"}
but that isn't sorted by "most recent".
I know that the obvious solution - reducing over the results of another view isn't supported. BigCouch supports chained map/reduce, but appears to be rather out of date / unsupported (last release 2012).
This seems like a rather common problem - what are some existing solutions (beyond "switch databases")?