module Executable

Overview

Handles query execution methods.

Defined in:

query/executable.cr

Instance Method Summary

Instance Method Detail

def all(as as_kind) #

Executes the query and returns all records.

Example Executing the query and returning all records

query.all(User)
=> [{"name" => "John", "age" => 30}]

[View source]
def all!(as as_kind) #

Executes the query and returns all records, raising an error if nil.

Example Executing the query and returning all records, raising an error if nil

query.all!(User)
=> [{"name" => "John", "age" => 30}]

[View source]
def each(as as_kind, &) #

Iterates over each result and yields it to the provided block.

Example Iterating over each result and yielding it to the provided block

query.each(User) do |user|
  puts user.name
end

[View source]
def first(as as_kind) #

Executes the query and returns the first record.

Example Executing the query and returning the first record

query.first(User)
=> {"name" => "John", "age" => 30}

[View source]
def first!(as as_kind) #

Executes the query and returns the first record, raising an error if nil.

Example Executing the query and returning the first record, raising an error if nil

query.first!(User)
=> {"name" => "John", "age" => 30}

[View source]
def get(as as_kind) #

Executes the query and returns a scalar value.

Example Executing the query and returning a scalar value

query.get(Int32)
=> 100

[View source]