abstract class Avram::Database

Defined in:

avram/database.cr
avram/database/column_info.cr
avram/database/database_info.cr
avram/database/table_info.cr

Class Method Summary

Instance Method Summary

Instance methods inherited from class Object

blank_for_validates_required? : Bool blank_for_validates_required?

Class Method Detail

def self.close_connections! #

Close all available connections as well as the DB


[View source]
def self.connections #

[View source]
def self.credentials #

[View source]
def self.database_info : DatabaseInfo #

[View source]
def self.delete #

Run a SQL DELETE on all tables in the database


[View source]
def self.exec(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#exec but with instrumentation


[View source]
def self.listen(*channels : String, &block : PQ::Notification -> ) : Nil #

Listens for pg_notify() calls on each channel in channels Yields a PQ::Notification object with channel, payload, and pid.

# pg_notify("callback", "123")
AppDatabase.listen("callback", "jobs") do |notification|
  notification.channel # => "callback"
  notification.payload # => "123"
end

[View source]
def self.lock_id : UInt64 | Nil #

[View source]
def self.lock_id=(lock_id : UInt64 | Nil) #

[View source]
def self.query(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#query but with instrumentation


[View source]
def self.query(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:query but with instrumentation


[View source]
def self.query_all(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#query_all but with instrumentation


[View source]
def self.query_all(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:query_all but with instrumentation


[View source]
def self.query_each(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:query_each but with instrumentation


[View source]
def self.query_one(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#query_one but with instrumentation


[View source]
def self.query_one(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:query_one but with instrumentation


[View source]
def self.query_one?(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#query_one? but with instrumentation


[View source]
def self.query_one?(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:"query_one?" but with instrumentation


[View source]
def self.rollback #

Rollback the current transaction


[View source]
def self.run(&) #

[View source]
def self.scalar(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#scalar but with instrumentation


[View source]
def self.setup_connection(&block : DB::Connection -> Nil) #

[View source]
def self.transaction(&) #

Wrap the block in a database transaction

AppDatabase.transaction do
  # Create, read, update
  # Force a rollback with AppDatabase.rollback
end

[View source]
def self.truncate(**named_args) #

Run a SQL TRUNCATE on all tables in the database


[View source]
def self.verify_connection #

[View source]

Instance Method Detail

def exec(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#exec but with instrumentation


[View source]
def publish_query_event(query, args_, args, queryable, &) #

[View source]
def query(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#query but with instrumentation


[View source]
def query(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:query but with instrumentation


[View source]
def query_all(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#query_all but with instrumentation


[View source]
def query_all(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:query_all but with instrumentation


[View source]
def query_each(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:query_each but with instrumentation


[View source]
def query_one(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#query_one but with instrumentation


[View source]
def query_one(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:query_one but with instrumentation


[View source]
def query_one?(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#query_one? but with instrumentation


[View source]
def query_one?(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &) #

Same as crystal-db's DB::QueryMethods#:"query_one?" but with instrumentation


[View source]
def scalar(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args) #

Same as crystal-db's DB::QueryMethods#scalar but with instrumentation


[View source]