I wonder if I can sort and find in Mongo but return only specific fields.
This command sorts the results by the field properties.aar but returns all the fields from the dataset.
db.samplecol.find().sort({"properties.aar":1})
Result (an example):
{ "_id" : ObjectId("5ad70f71f2119236741ffb03"), "geometry" : { "type" : "Point", "coordinates" : [ 119.6164, 4.7121 ] }, "type" : "Feature", "properties" : { "STATUS" : "0", "TIMESTAMP" : "2013-12-31 18:49:00.000", "aar" : "205580000", "COURSE" : "175", "SPEED" : "153", "HEADING" : "176" } }
I wonder if I can return only the geometry.coordinates.
Update
The results aren't sorted based on the field properties.aar. The code that works for me is (pymongo):
db.samplecol.find({}, {"properties.aar":1,"geometry.coordinates":1, "_id":0}).sort([("properties.aar", pymongo.ASCENDING)])
So, @Neil Lunn please don't judge so fast to mark a question.