mongo-ruby-driver/test/mongo-qa/find1

16 lines
533 B
Ruby

#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), '_common.rb')
db = Connection.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
if $DEBUG
db.drop_collection('c')
c = db.collection('c')
(5..15).each { |i| c.insert(:x => 0, :y => i, :z => (i+64).chr) }
(1..50).each { |i| c.insert(:x => 1, :y => i, :z => (i+64).chr) }
(5..15).each { |i| c.insert(:x => 2, :y => i, :z => (i+64).chr) }
end
cursor = db.collection('c').find({'x' => 1}, :sort => 'y', :skip => 20, :limit => 10)
cursor.each { |row| puts row['z'] }