Class: Riak::YzQuery::QueryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/riak/yz_query/query_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(bucket) ⇒ QueryBuilder

Returns a new instance of QueryBuilder.



4
5
6
# File 'lib/riak/yz_query/query_builder.rb', line 4

def initialize(bucket)
  @bucket = bucket
end

Instance Method Details

#initialize_from_opts(opts) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/riak/yz_query/query_builder.rb', line 8

def initialize_from_opts(opts)
  @bucket = opts[:bucket]
  @where_clauses = opts[:where_clauses]
  @order_clauses = opts[:order_clauses]
  @limit = opts[:limit]
  @offset = opts[:offset]
end

#keysObject



32
33
34
# File 'lib/riak/yz_query/query_builder.rb', line 32

def keys
  @keys ||= results['docs'].map{|d| d['_yz_rk']}
end

#limit(lim) ⇒ Object



24
25
26
# File 'lib/riak/yz_query/query_builder.rb', line 24

def limit(lim)
  chain limit: lim
end

#offset(off) ⇒ Object



28
29
30
# File 'lib/riak/yz_query/query_builder.rb', line 28

def offset(off)
  chain offset: off
end

#order(opts) ⇒ Object



20
21
22
# File 'lib/riak/yz_query/query_builder.rb', line 20

def order(opts)
  chain order_clauses: order_clauses.consume(opts)
end

#to_yz_queryObject



40
41
42
# File 'lib/riak/yz_query/query_builder.rb', line 40

def to_yz_query
  where_clauses.to_yz_query
end

#valuesObject



36
37
38
# File 'lib/riak/yz_query/query_builder.rb', line 36

def values
  @bucket.get_many keys
end

#where(opts) ⇒ Object



16
17
18
# File 'lib/riak/yz_query/query_builder.rb', line 16

def where(opts)
  chain where_clauses: where_clauses.consume(opts)
end