how to query this data in MongoDB?
So, the data is look like that:
{"_id":"asfasbasdf123", session:"lastAccess:1002040506, myd:'ataber244' "}
lastAccess is the Date.开发者_开发技巧 the number is the UTC date number.
how should I query for data that with "lastAccess" date less than certain days? the lastAccess in part of the string in the "session" variable.
Thanks.
- By the way, I mean command line.
So the first big question is "why is session a string".
{"_id":"asfasbasdf123", session:"lastAccess:1002040506, myd:'ataber244' "}
As written, I don't know of any simply query. You basically have to do a Regular Expression and then perform a comparison, but this is not trivial.
Is it possible to do the following:
{"_id":"asfasbasdf123", session: { lastAccess: 1002040506, myd: 'ataber244' }}
If so, then you can do the following:
db.sessions.find( { 'session.lastAccess' : { $lt: your_timestamp } } )
精彩评论