class
CQL::ActiveRecord::Queryable::ChainableQuery(Target)
- CQL::ActiveRecord::Queryable::ChainableQuery(Target)
- Reference
- Object
Overview
A chainable query class that wraps a CQL::Query and knows about the model type it's querying
Defined in:
active_record/queryable.crConstructors
Macro Summary
Instance Method Summary
-
#all
Execute the query and return all matching records - @return [Array(T)] The matching records
-
#count
Count the number of matching records - @return [Int64] The number of matching records
-
#first
Execute the query and return the first matching record - @return [T?] The first matching record, or nil if none found
-
#first!
Execute the query and return the first matching record, raising if none found - @return [T] The first matching record - @raise [DB::NoResultsError] If no records found
-
#group_by(*fields)
Add a group by clause to the query - @param fields [Array(Symbol)] The fields to group by - @return [ChainableQuery] The chainable query
-
#join(table : Symbol, on)
Add a join clause to the query - @param table [Symbol] The table to join - @param on [Hash(Symbol, Symbol) | NamedTuple] The join condition - @return [ChainableQuery] The chainable query
-
#limit(limit : Int32)
Add a limit clause to the query - @param limit [Int32] The maximum number of records to return - @return [ChainableQuery] The chainable query
-
#offset(offset : Int32)
Add an offset clause to the query - @param offset [Int32] The number of records to skip - @return [ChainableQuery] The chainable query
-
#order(**fields)
Add an order clause to the query - @param fields [Hash(Symbol, Symbol)] The fields to order by - @return [ChainableQuery] The chainable query
-
#select(*fields)
Add a select clause to the query - @param fields [Array(Symbol)] The fields to select - @return [ChainableQuery] The chainable query
-
#where(**fields)
Add a where clause to the query - @param fields [Hash(Symbol, DB::Any)] The fields to match - @return [ChainableQuery] The chainable query
Constructor Detail
Macro Detail
Instance Method Detail
Execute the query and return the first matching record
- @return [T?] The first matching record, or nil if none found
Execute the query and return the first matching record, raising if none found
- @return [T] The first matching record
- @raise [DB::NoResultsError] If no records found
Add a group by clause to the query
- @param fields [Array(Symbol)] The fields to group by
- @return [ChainableQuery] The chainable query
Add a join clause to the query
- @param table [Symbol] The table to join
- @param on [Hash(Symbol, Symbol) | NamedTuple] The join condition
- @return [ChainableQuery] The chainable query
Add a limit clause to the query
- @param limit [Int32] The maximum number of records to return
- @return [ChainableQuery] The chainable query
Add an offset clause to the query
- @param offset [Int32] The number of records to skip
- @return [ChainableQuery] The chainable query
Add an order clause to the query
- @param fields [Hash(Symbol, Symbol)] The fields to order by
- @return [ChainableQuery] The chainable query
Add a select clause to the query
- @param fields [Array(Symbol)] The fields to select
- @return [ChainableQuery] The chainable query
Add a where clause to the query
- @param fields [Hash(Symbol, DB::Any)] The fields to match
- @return [ChainableQuery] The chainable query