Building a query to pipeline with case


Im trying to create this query in mongo, I can do some og it in the aggregation but not in a pipeline for charts.

any ideas?

SELECT m.attendees,  count(m._id) 'meetings_calendar',
      count(distinct(j.meetingID)) as 'meetee_meetings',
    WHEN count(distinct(j.meetingID)) = 0 THEN 'new user'
    WHEN   count(distinct(j.meetingID)) between 1 and 2 THEN 'Not So Active User'
   WHEN  count(distinct(j.meetingID)) between 3 and 6 THEN 'Active User'
    ELSE 'Boom User'
END AS userType
FROM meetings as m  left join jobs as j on m._id = j.meetingID
GROUP BY m.attendees

did you tried looking into

You could do first lookup then aggregation and based on count(distinct(j.meetingID)) value you could use switch to get desired result.