Class: AgnosticBackend::Queryable::QueryBuilder
- Inherits:
-
Object
- Object
- AgnosticBackend::Queryable::QueryBuilder
show all
- Defined in:
- lib/agnostic_backend/queryable/query_builder.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of QueryBuilder.
8
9
10
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 8
def initialize(index)
@index = index
end
|
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
5
6
7
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 5
def index
@index
end
|
#query ⇒ Object
Returns the value of attribute query.
6
7
8
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 6
def query
@query
end
|
Instance Method Details
#build(**options) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 51
def build(**options)
query = create_query(self, **options)
query.children << build_where_expression if @criterion
query.children << build_select_expression if @projections
query.children << build_order_expression if @order_qualifiers
query.children << build_limit_expression if @limit
query.children << build_offset_expression if @offset
query.children << build_filter_expression if @filter
query.children << build_scroll_cursor_expression if @scroll_cursor
@query = query
end
|
#criteria_builder ⇒ Object
12
13
14
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 12
def criteria_builder
CriteriaBuilder.new(self)
end
|
#filter(filter) ⇒ Object
46
47
48
49
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 46
def filter(filter)
@filter = filter
self
end
|
#limit(value) ⇒ Object
31
32
33
34
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 31
def limit(value)
@limit = value
self
end
|
#offset(value) ⇒ Object
36
37
38
39
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 36
def offset(value)
@offset = value
self
end
|
#order(attribute, direction) ⇒ Object
26
27
28
29
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 26
def order(attribute, direction)
(@order_qualifiers ||= []).push build_order_qualifier(attribute, direction)
self
end
|
41
42
43
44
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 41
def scroll_cursor(value)
@scroll_cursor = value
self
end
|
#select(*attributes) ⇒ Object
21
22
23
24
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 21
def select(*attributes)
(@projections ||= []).push(*attributes)
self
end
|
#where(criterion) ⇒ Object
16
17
18
19
|
# File 'lib/agnostic_backend/queryable/query_builder.rb', line 16
def where(criterion)
@criterion = criterion
self
end
|