2009-02-05 19:24:59 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
|
|
|
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
|
|
|
|
2009-02-05 21:00:45 +00:00
|
|
|
if $DEBUG
|
2009-02-05 19:47:33 +00:00
|
|
|
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
|
|
|
|
|
2009-02-05 19:24:59 +00:00
|
|
|
cursor = db.collection('c').find({'x' => 1}, :sort => 'y', :offset => 20, :limit => 10)
|
|
|
|
cursor.each { |row| puts row['z'] }
|