Revision 2bef00733b61 () - Diff

Link to this snippet: https://friendpaste.com/2vxFfNL2vV4sPXJo6XpxBQ
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Requires CouchDB trunk 0.9 with latest RelaxDB
# or RelaxDB 0.2.0 with CouchDB 0.8

require 'rubygems'
require 'relaxdb'

RelaxDB.configure :host => "localhost", :port => 5984, :logger => Logger.new(STDOUT)
RelaxDB.use_db "scratch"

class Datum < RelaxDB::Document
property :folk_cde
property :lat
property :lng
end

Datum.all.destroy!

codes = "a".."c"
codes.each do |c|
3.times do |i|
Datum.new(:folk_cde => c, :lat => i, :lng => i).save
end
end

datum = Datum.all.sorted_by(:folk_cde, :lat, :lng) do |q|
q.startkey(["a"]).endkey(["a", {}, {}])
end

puts datum.inspect