开发者

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 } } )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜