ruby - mongo get first data after sorting by descending -
how first data on mongo after sorting data desc. example :
i'm using tutorial in app : mongo ruby
i'm typing in console :
client = mongo::client.new db = client['example-db'] coll = db['example-collection'] collect_data = coll.sort("desc created")
result collect_data.count = 11
how first data collect_data
?
need help, master
try
collect_data[0]
or
collect_data.to_a[0]
Comments
Post a Comment