module Rome::Query

Overview

Most methods are delegated to a Collection(T) object.

Defined in:

query.cr
query/builder.cr
query/cache.cr
query/iterator.cr
query/methods.cr

Instance Method Summary

Instance Method Detail

def all : Collection(self) #

[View source]
def average(column_name : Symbol | String) : Float64 #

[View source]
def count(column_name : Symbol | String = "*", distinct = false) : Int64 #

[View source]
def distinct(value = true) : Collection(self) #

[View source]
def exists?(id) : Bool #

[View source]
def find(id) : self #

[View source]
def find?(id) : self | Nil #

[View source]
def find_all_by_sql(sql : String, *args) : Array(self) #

Loads records by raw SQL query. You may refer to arguments with ? in the SQL query, and pass them to the method. For example:

users = User.find_all_by_sql(<<-SQL, "julien")
  SELECT * FROM "users" WHERE username = ?
  SQL

[View source]
def find_by(**args) : self #

[View source]
def find_by?(**args) : self | Nil #

[View source]
def find_one_by_sql(sql : String, *args) : self #

Loads one record by raw SQL query. You may refer to arguments with ? in the SQL query, and pass them to the method. For example:

user = User.find_one_by_sql(<<-SQL, "julien")
  SELECT * FROM "users" WHERE username = ? LIMIT 1
  SQL

Raises a RecordNotFound exception when no record could be found in the database.


[View source]
def find_one_by_sql?(sql : String, *args) : self | Nil #

Same as #find_one_by_sql but returns nil when no record could be found in the database.


[View source]
def first : self #

[View source]
def first? : self | Nil #

[View source]
def ids : Array #

[View source]
def last : self #

[View source]
def last? : self | Nil #

[View source]
def limit(value : Int32) : Collection(self) #

[View source]
def maximum(column_name : Symbol | String) #

[View source]
def minimum(column_name : Symbol | String) #

[View source]
def none : Collection(self) #

[View source]
def offset(value : Int32) : Collection(self) #

[View source]
def order(columns : Hash(Symbol, Symbol)) : Collection(self) #

[View source]
def order(*columns : Symbol | String) : Collection(self) #

[View source]
def order(**columns) : Collection(self) #

[View source]
def pluck(column_name : Symbol | String) : Array(Value) #

[View source]
def reorder(columns : Hash(Symbol, Symbol)) : Collection(self) #

[View source]
def reorder(*columns : Symbol | String) : Collection(self) #

[View source]
def reorder(**columns) : Collection(self) #

[View source]
def select(sql : String) : Collection(self) #

[View source]
def select(*columns : Symbol) : Collection(self) #

[View source]
def sum(column_name : Symbol | String) : Int64 | Float64 #

[View source]
def take : self #

[View source]
def take? : self | Nil #

[View source]
def where(conditions : Hash(Symbol, Value | Array(Value)) | NamedTuple) : Collection(self) #

[View source]
def where(sql : String, *args : Value) : Collection(self) #

[View source]
def where(**conditions) : Collection(self) #

[View source]
def where_not(conditions : Hash(Symbol, Value | Array(Value)) | NamedTuple) : Collection(self) #

[View source]
def where_not(**conditions) : Collection(self) #

[View source]