Class: DynamoidAdvancedWhere::QueryBuilder
- Inherits:
- 
      Object
      
        - Object
- DynamoidAdvancedWhere::QueryBuilder
 
- Defined in:
- lib/dynamoid_advanced_where/query_builder.rb
Instance Attribute Summary collapse
- 
  
    
      #klass  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute klass. 
- 
  
    
      #projected_fields  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute projected_fields. 
- 
  
    
      #record_limit  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute record_limit. 
- 
  
    
      #root_node  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute root_node. 
- 
  
    
      #start_hash  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute start_hash. 
Instance Method Summary collapse
- #batch_update ⇒ Object
- 
  
    
      #initialize(klass:, projected_fields: [], record_limit: nil, start_hash: nil, root_node: nil, &blk)  ⇒ QueryBuilder 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of QueryBuilder. 
- #limit(value) ⇒ Object
- #project(*fields) ⇒ Object
- #query_materializer ⇒ Object
- #start(key_hash) ⇒ Object
- #upsert(*args) ⇒ Object
- #where(other_builder = nil, &blk) ⇒ Object (also: #and)
Constructor Details
#initialize(klass:, projected_fields: [], record_limit: nil, start_hash: nil, root_node: nil, &blk) ⇒ QueryBuilder
Returns a new instance of QueryBuilder.
| 13 14 15 16 17 18 19 20 21 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 13 def initialize(klass:, projected_fields: [], record_limit: nil, start_hash: nil, root_node: nil, &blk) self.klass = klass self.root_node = root_node || Nodes::RootNode.new(klass: klass, &blk) self.start_hash = start_hash self.record_limit = record_limit self.projected_fields = projected_fields freeze end | 
Instance Attribute Details
#klass ⇒ Object
Returns the value of attribute klass.
| 9 10 11 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 9 def klass @klass end | 
#projected_fields ⇒ Object
Returns the value of attribute projected_fields.
| 9 10 11 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 9 def projected_fields @projected_fields end | 
#record_limit ⇒ Object
Returns the value of attribute record_limit.
| 9 10 11 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 9 def record_limit @record_limit end | 
#root_node ⇒ Object
Returns the value of attribute root_node.
| 9 10 11 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 9 def root_node @root_node end | 
#start_hash ⇒ Object
Returns the value of attribute start_hash.
| 9 10 11 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 9 def start_hash @start_hash end | 
Instance Method Details
#batch_update ⇒ Object
| 27 28 29 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 27 def batch_update BatchedUpdater.new(query_builder: self) end | 
#limit(value) ⇒ Object
| 57 58 59 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 57 def limit(value) dup_with_changes(record_limit: value) end | 
#project(*fields) ⇒ Object
| 53 54 55 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 53 def project(*fields) dup_with_changes(projected_fields: projected_fields + fields) end | 
#query_materializer ⇒ Object
| 23 24 25 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 23 def query_materializer QueryMaterializer.new(query_builder: self) end | 
#start(key_hash) ⇒ Object
| 61 62 63 64 65 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 61 def start(key_hash) return self if key_hash.nil? || key_hash.empty? dup_with_changes(start_hash: key_hash) end | 
#upsert(*args) ⇒ Object
| 31 32 33 34 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 31 def upsert(*args) update_fields = args. batch_update.set_values(update_fields).apply(*args) end | 
#where(other_builder = nil, &blk) ⇒ Object Also known as: and
| 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # File 'lib/dynamoid_advanced_where/query_builder.rb', line 36 def where(other_builder = nil, &blk) raise 'cannot use a block and an argument' if other_builder && blk other_builder = self.class.new(klass: klass, &blk) if blk raise 'passed argument must be a query builder' unless other_builder.is_a?(self.class) local_root_node = root_node self.class.new(klass: klass) do Nodes::AndNode.new( other_builder.root_node.child_node, local_root_node.child_node ) end end |