How to do sorting based on DateTime using MongoDB

307 views
Skip to first unread message

Rama krishna boyina

unread,
Mar 27, 2012, 3:28:01 AM3/27/12
to mongodb-user
Hi,

I have a Datagrid.In that DateTime column is there.
Datagrid is automatically refresh every time.
I wanna do sorting.Latest record will display in Datagrid.
So i wanna sort using Datetime in decending order?
If i have millions of records whether its working or not

Thanks,
Rama Krishna

Sam Millman

unread,
Mar 27, 2012, 7:51:37 AM3/27/12
to mongod...@googlegroups.com
Assuming your datetime colum is 'ts' then something like:

db.col.find({}).sort({'ts': 1});

Will work


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Reply all
Reply to author
Forward
0 new messages