Difference between revisions of "MongoDb"

From Hawk Wiki
Jump to: navigation, search
Line 5: Line 5:
 
</pre>
 
</pre>
 
search last 5 minutes
 
search last 5 minutes
</pre>
+
<pre>
 
db.getCollection('XXX').find({t: {$gte: new Date(ISODate().getTime() - 1000 * 60 * 5)}})
 
db.getCollection('XXX').find({t: {$gte: new Date(ISODate().getTime() - 1000 * 60 * 5)}})
 
</pre>
 
</pre>

Revision as of 22:31, 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)}})