I have a big collection of event
documents in a MongoDB collection. Fields in each document include:
userId
(database id, if user is logged in)visitorId
(cookie id, always exists)eventType
(the type of event the user has just done)
One eventType
in particular is of interest - the "purchase" type. What I'm trying to do is run a query which basically says:
Get a list of all the purchase events by users who performed a particular event.
Originally my idea was to simply download a list of all the users who performed an event, and then use that as a massive query condition. However this feels ugly, and I'd imagine for larger queries, it'd be quite expensive on the memory front.
Is there a better/smarter way?