class CQL::ActiveRecord::Queryable::ChainableQuery(Target)

Overview

A chainable query class that wraps a CQL::Query and knows about the model type it's querying

Defined in:

active_record/queryable.cr

Constructors

Macro Summary

Instance Method Summary

Constructor Detail

def self.new(query : CQL::Query) #

[View source]

Macro Detail

macro method_missing(call) #

[View source]

Instance Method Detail

def all #

Execute the query and return all matching records

  • @return [Array(T)] The matching records

[View source]
def count #

Count the number of matching records

  • @return [Int64] The number of matching records

[View source]
def first #

Execute the query and return the first matching record

  • @return [T?] The first matching record, or nil if none found

[View source]
def 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

[View source]
def 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

[View source]
def 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

[View source]
def 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

[View source]
def offset(offset : Int32) #

Add an offset clause to the query

  • @param offset [Int32] The number of records to skip
  • @return [ChainableQuery] The chainable query

[View source]
def order(**fields) #

Add an order clause to the query

  • @param fields [Hash(Symbol, Symbol)] The fields to order by
  • @return [ChainableQuery] The chainable query

[View source]
def select(*fields) #

Add a select clause to the query

  • @param fields [Array(Symbol)] The fields to select
  • @return [ChainableQuery] The chainable query

[View source]
def where(**fields) #

Add a where clause to the query

  • @param fields [Hash(Symbol, DB::Any)] The fields to match
  • @return [ChainableQuery] The chainable query

[View source]