Difference between revisions of "MongoDb"

From Hawk Wiki
Jump to: navigation, search
(Created page with "Search by timestamp <pre> db.getCollection('XXX').find({t: {$gte: new ISODate("2018-01-01T21:56:47Z")}}); </pre>")
 
Line 1: Line 1:
 
Search by timestamp
 
Search by timestamp
 
<pre>
 
<pre>
 +
search from a certain timestamp
 
db.getCollection('XXX').find({t: {$gte: new ISODate("2018-01-01T21:56:47Z")}});
 
db.getCollection('XXX').find({t: {$gte: new ISODate("2018-01-01T21:56:47Z")}});
 +
search last 5 minutes
 +
db.getCollection('XXX').find({t: {$gte: new Date(ISODate().getTime() - 1000 * 60 * 5)}})
 
</pre>
 
</pre>

Revision as of 22:30, 1 January 2018

Search by timestamp

search from a certain timestamp
db.getCollection('XXX').find({t: {$gte: new ISODate("2018-01-01T21:56:47Z")}});
search last 5 minutes
db.getCollection('XXX').find({t: {$gte: new Date(ISODate().getTime() - 1000 * 60 * 5)}})