How can get newest document just using the map
问题 I have document like the following, I want to use map function to get the latest status with given UserId doc1: _id=id1, UserId='ABC', status='OPEN',... doc2: _id=id2, UserId='BCD', status='OPEN', ..... doc3: _id=id3, UserId='ABC', status='CLOSED'.... For a given userid, if it related two status: open and close, then return that document with close status document For a given userid, if it related just open status, then return that document with open status document doc1: _id=id1, UserId='ABC