class

User::BaseQuery

Inherits Avram::PrimaryKeyQueryable < Avram::Queryable < Enumerable < Reference < Object

Constructors

all

Class methods

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.

find(id) : T
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
first?

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

([1, 2, 3]).first?   # => 1
([] of Int32).first? # => nil
last
last?
new_with_existing_query(query : Avram::QueryBuilder)
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?.

preload_bearer_logins(record : User, force : Bool = false) : User
preload_bearer_logins(record : User, force : Bool = false, &) : User
preload_bearer_logins(record : User, preload_query : BearerLogin::BaseQuery, force : Bool = false) : User
preload_bearer_logins(records : Enumerable(User), force : Bool = false) : Array(User)
preload_bearer_logins(records : Enumerable(User), force : Bool = false, &) : Array(User)
preload_bearer_logins(records : Enumerable(User), preload_query : BearerLogin::BaseQuery, force : Bool = false) : Array(User)
preload_email_confirmations(record : User, force : Bool = false) : User
preload_email_confirmations(record : User, force : Bool = false, &) : User
preload_email_confirmations(record : User, preload_query : EmailConfirmation::BaseQuery, force : Bool = false) : User
preload_email_confirmations(records : Enumerable(User), force : Bool = false) : Array(User)
preload_email_confirmations(records : Enumerable(User), force : Bool = false, &) : Array(User)
preload_email_confirmations(records : Enumerable(User), preload_query : EmailConfirmation::BaseQuery, force : Bool = false) : Array(User)
preload_logins(record : User, force : Bool = false) : User
preload_logins(record : User, force : Bool = false, &) : User
preload_logins(record : User, preload_query : Login::BaseQuery, force : Bool = false) : User
preload_logins(records : Enumerable(User), force : Bool = false) : Array(User)
preload_logins(records : Enumerable(User), force : Bool = false, &) : Array(User)
preload_logins(records : Enumerable(User), preload_query : Login::BaseQuery, force : Bool = false) : Array(User)
preload_password_resets(record : User, force : Bool = false) : User
preload_password_resets(record : User, force : Bool = false, &) : User
preload_password_resets(record : User, preload_query : PasswordReset::BaseQuery, force : Bool = false) : User
preload_password_resets(records : Enumerable(User), force : Bool = false) : Array(User)
preload_password_resets(records : Enumerable(User), force : Bool = false, &) : Array(User)
preload_password_resets(records : Enumerable(User), preload_query : PasswordReset::BaseQuery, force : Bool = false) : Array(User)
truncate(*, cascade : Bool = false, restart_identity : Bool = false)

Removes all data from a table using the TRUNCATE postgres SQL command.

You should run this command with cascade: true if your table columns are referenced by other foreign key constraints. Use delete instead if you don't want to accidentally delete rows referenced elsewhere.

To delete all data referenced by foreign keys as well, set cascade to true.

Instance methods

clone

Returns a copy of self with all instance variables cloned.

created_at(value)
created_at
email(value)
email
find(id) : T
first_name(value)
first_name
full_join_bearer_logins(where_bearer_logins : BearerLogin::BaseQuery)
full_join_bearer_logins
full_join_email_confirmations(where_email_confirmations : EmailConfirmation::BaseQuery)
full_join_email_confirmations
full_join_logins(where_logins : Login::BaseQuery)
full_join_logins
full_join_password_resets(where_password_resets : PasswordReset::BaseQuery)
full_join_password_resets
id(value)
id
inner_join_bearer_logins(where_bearer_logins : BearerLogin::BaseQuery)
inner_join_bearer_logins
inner_join_email_confirmations(where_email_confirmations : EmailConfirmation::BaseQuery)
inner_join_email_confirmations
inner_join_logins(where_logins : Login::BaseQuery)
inner_join_logins
inner_join_password_resets(where_password_resets : PasswordReset::BaseQuery)
inner_join_password_resets
join_bearer_logins(where_bearer_logins : BearerLogin::BaseQuery)
join_bearer_logins
join_email_confirmations(where_email_confirmations : EmailConfirmation::BaseQuery)
join_email_confirmations
join_logins(where_logins : Login::BaseQuery)
join_logins
join_password_resets(where_password_resets : PasswordReset::BaseQuery)
join_password_resets
last_name(value)
last_name
left_join_bearer_logins(where_bearer_logins : BearerLogin::BaseQuery)
left_join_bearer_logins
left_join_email_confirmations(where_email_confirmations : EmailConfirmation::BaseQuery)
left_join_email_confirmations
left_join_logins(where_logins : Login::BaseQuery)
left_join_logins
left_join_password_resets(where_password_resets : PasswordReset::BaseQuery)
left_join_password_resets
level(value)
level
password_digest(value)
password_digest
preload_bearer_logins(preload_query : BearerLogin::BaseQuery) : self
preload_bearer_logins
preload_bearer_logins
preload_email_confirmations(preload_query : EmailConfirmation::BaseQuery) : self
preload_email_confirmations
preload_email_confirmations
preload_logins(preload_query : Login::BaseQuery) : self
preload_logins
preload_logins
preload_password_resets(preload_query : PasswordReset::BaseQuery) : self
preload_password_resets
preload_password_resets
right_join_bearer_logins(where_bearer_logins : BearerLogin::BaseQuery)
right_join_bearer_logins
right_join_email_confirmations(where_email_confirmations : EmailConfirmation::BaseQuery)
right_join_email_confirmations
right_join_logins(where_logins : Login::BaseQuery)
right_join_logins
right_join_password_resets(where_password_resets : PasswordReset::BaseQuery)
right_join_password_resets
settings(value)
settings
update(email : String | Avram::Nothing = IGNORE, password_digest : String | Avram::Nothing = IGNORE, settings : UserSettings | Avram::Nothing = IGNORE, id : Int64 | Avram::Nothing = IGNORE, created_at : Time | Avram::Nothing = IGNORE, first_name : String | Avram::Nothing = IGNORE, last_name : String | Avram::Nothing = IGNORE, level : UserLevel | Avram::Nothing = IGNORE, updated_at : Time | Avram::Nothing = IGNORE) : Int64

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)
updated_at(value)
updated_at
where_bearer_logins(assoc_query : BearerLogin::BaseQuery, auto_inner_join : Bool = true)

DEPRECATED Use any of the join methods with a where_bearer_logins argument instead

where_email_confirmations(assoc_query : EmailConfirmation::BaseQuery, auto_inner_join : Bool = true)

DEPRECATED Use any of the join methods with a where_email_confirmations argument instead

where_logins(assoc_query : Login::BaseQuery, auto_inner_join : Bool = true)

DEPRECATED Use any of the join methods with a where_logins argument instead

where_password_resets(assoc_query : PasswordReset::BaseQuery, auto_inner_join : Bool = true)

DEPRECATED Use any of the join methods with a where_password_resets argument instead

Macros

generate_criteria_method(name, type)