MongoDB - How to query Embedded Documents from a collection MongoDB - How to query Embedded Documents from a collection mongodb mongodb

MongoDB - How to query Embedded Documents from a collection


Here is how you get the result for your first query:

var start = new Date(2010, 11, 25);var end = new Date(2010, 12, 1);db.users.distinct("userid", {"signup.dt" : {$gte: start, $lte: end},      "activity" : {"$elemMatch" : { dt: {$gte: start, $lte: end}}}});

The second is like it with adding 7 days to the start and end date to the dates after activity.