Performing case-statement in mongodb aggregation framework
问题 I'm evaluating how well the MongoDB aggregation framework suits our needs as we are currently running on top of SQL Server. I'm having a hard time performing a specific query: Say I have the following pseudo records (modeled as columns in a sql table and as a full document in a mongodb collection) { name: 'A', timespent: 100, }, { name: 'B', timespent: 200, }, { name: 'C', timespent: 300, }, { name: 'D', timespent: 400, }, { name: 'E', timespent: 500, } I want to group the timespent field in