KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to return the results from the find query with the help of sortaing based on lastUpdated field . Currently i have seen two ways First Approach BasicDBObject query = new BasicDBObject(); query.put("updated_at","-1"); query.put(MONGO_ATTR_SYMBOL, "" + symbol); DBCursor cursor = DBcollection.find(query).sort(query); Second Approach DBCursor cursor = DBcollection.find(query,new BasicDBObject("sort", new BasicDBObject("lastUpdated ", -1))); What is the best option to work with any ideas ??
Tags (comma-separated)
Save Edits
Cancel