Difference between revisions of "MongoDb"

From Hawk Wiki
Jump to: navigation, search
Line 1: Line 1:
Search by timestamp
+
===Search by timestamp===
<pre>
+
 
search from a certain timestamp
 
search from a certain timestamp
 +
<pre>
 
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")}});
 +
</pre>
 
search last 5 minutes
 
search last 5 minutes
 +
</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: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 </pre> db.getCollection('XXX').find({t: {$gte: new Date(ISODate().getTime() - 1000 * 60 * 5)}}) </pre>