python - How to get documents where KEY is greater than X -
i recording user's daily usage of platform.
structures of documents in mongodb that:
_id: x day1:{ logincount = 4 somedict { x:y, z:m } } day2:{ logincount = 5 somedict { a:b, c:d } } then, need last 2 day's user stats belongs user x.
how can values days greater 2 days ago? (like using '$gte' command?)
ok, if insist on scheme try this:
{ _id: usemongokeyhere userid: x days: [ {day:isodate(2013-08-12 00:00), logincount: 10, #morestuff }, {day:isodate(2013-08-13 00:00), logincount: 11, #morestuff }, ] }, #more users then can query like:
db.items.find( {"days.day":{$gte:isodate("2013-08-30t00:00:00.000z"), $lt: isodate("2013-08-31t00:00:00.000z") } } )
Comments
Post a Comment