module

Avram::Queryable(T)

Inherits Enumerable

Instance methods

add_preload
Source
any?

Returns true if at least one of the collection's members is truthy.

[nil, true, 99].any? # => true
[nil, false].any?    # => false
([] of Int32).any?   # => false
  • #present? does not consider truthiness of elements.
  • #any?(&) and #any(pattern) allow custom conditions.

NOTE: #any? usually has the same semantics as #present?. They only differ if the element type can be falsey (i.e. T <= Nil || T <= Pointer || T <= Bool). It's typically advised to prefer #present? unless these specific truthiness semantics are required.

Source
cache_key(operation : Symbol) : String
Source
cache_key
Source
cache_store
Source
delete

Delete the records using the query's where clauses, or all records if no wheres are added.

Returns the number of deleted records as Int64.

# DELETE FROM users WHERE age < 21
UserQuery.new.age.lt(21).delete
Source
distinct
Source
distinct_on
Source
each

Must yield this collection's elements to the block.

Source
exec_scalar
Source
first

Returns the first element in the collection. Raises Enumerable::EmptyError if the collection is empty.

([1, 2, 3]).first   # => 1
([] of Int32).first # raises Enumerable::EmptyError
Source
first?

Returns the first element in the collection. When the collection is empty, returns nil.

([1, 2, 3]).first?   # => 1
([] of Int32).first? # => nil
Source
for_update
Source
group
Source
group_count
Source
join(join_clause : Avram::Join::SqlClause) : self
Source
last
Source
last?
Source
limit(amount) : self
Source
merge_query(query_to_merge : Avram::QueryBuilder) : self
Source
none
Source
none?

Returns true if all of the elements of the collection are falsey.

[nil, false].none?       # => true
[nil, false, true].none? # => false

It's the opposite of all?.

Source
offset(amount) : self
Source
or

Run the or block first to grab the last WHERE clause and set its conjunction to OR. Then call yield to set the next set of ORs

Source
order_by(column, direction, null_sorting : Avram::OrderBy::NullSorting = :default) : self
Source
order_by(order : Avram::OrderByClause) : self
Source
preloads
Source
primary_key_name(*args, **options)
Source
primary_key_name(*args, **options, &)
Source
query
Source
random_order
Source
read_database(*args, **options)
Source
read_database(*args, **options, &)
Source
reset_limit
Source
reset_offset
Source
reset_order
Source
reset_where
Source
results
Source
schema_class
Source
select_count
Source
table_name(*args, **options)
Source
table_name(*args, **options, &)
Source
to_prepared_sql
Source
to_sql
Source
update

Update the records using the query's where clauses, or all records if no wheres are added.

Returns the number of records updated as Int64.

# Update all comments with the word "spam" as spam
CommentQuery.new.body.ilike("spam").update(spam: true)
Source
where(column : Symbol, value) : self
Source
where(sql_clause : Avram::Where::SqlClause) : self
Source
where(statement : String, *bind_vars) : self
Source
where(statement : String, *, args bind_vars : Array) : self
Source
where
Source
write_database(*args, **options)
Source
write_database(*args, **options, &)
Source

Nested types