Skip to content

Instantly share code, notes, and snippets.

@iconara
Created April 19, 2011 12:51
Show Gist options
  • Save iconara/927443 to your computer and use it in GitHub Desktop.
Save iconara/927443 to your computer and use it in GitHub Desktop.
require 'mongo'
mongo = Mongo::Connection.new
db = mongo.db('test')
collection = db.collection('helloworld')
collection.remove
collection.insert({:x => 3})
collection.insert({:x => 2})
collection.insert({:x => 5})
OPTIONS = {:sort => :x}
3.times do
p collection.find({}, OPTIONS).to_a.map { |d| d['x'] }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment