When querying a large Mongo database I often only want a subset of documents - typically the N most recently added. The ‘Number of rows’ drop-down box in Exploratory’s Import MongoDB dialogue box allows you to specify 100, 1000, 1000 etc. rows but for my database this happens to return the first and oldest N rows
Is there a way of querying for the say 100 most recent rows?
I have tried:
{“logged_datetime”: {"$gte": ISODate(“2016-10-13 00:00:00”)}} - but I don;t think it likes ISODate(), and;
{"$sort": {“logged_datetime”: -1}} - but I don’t think the query box allows any other operations other than specifying the $match part of the query.
Are there any plans to support parsing full MongoDB pipeline queries e.g.
db.collection.find({…}).sort({…}).limit(10) or;
As to ISODate, it could be that it’s expecting a normal JSON convension, so you might want to add single quotes like
‘ISODate(“2016-10-13 00:00:00”)’
I haven’t tested this, so not 100% sure. We’ll check this here as well.
As to other verbs, we’re going to add a support of sort, limit and other parameters for the query operation and support the aggregate operation as well. Basically, we’ll add a full support of ‘find’ and ‘aggregate’ functions, which you can find in this doc.
worked on one collections (‘collection_1’) but on another (larger) collection (‘collection_2’) it did not It reported:
Error
invalid response (expecting SEXP)
The date time filtered code didn’t work in 3T MongoChef (Core 4.2.0) on either collection :
db.collection_1.find({“logged”:{"$gt": { “$date” : “2016-10-16T00:00:00Z” } } }).limit(2)
db.collection_2.find({“logged”:{"$gt": { “$date” : “2016-10-16T00:00:00Z” } } }).limit(2)
it returns 0 documents.
(BTW:
I’m still investigating a third error that only happens on collection_3 when I use: