abstract class Avram::Database
- Avram::Database
- Reference
- Object
Defined in:
avram/database.crClass Method Summary
-
.close_connections!
Close all available connections as well as the DB
- .connections
- .credentials
- .database_info : DatabaseInfo
-
.delete
Run a SQL
DELETE
on all tables in the database -
.exec(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args)
Same as crystal-db's
DB::QueryMethods#exec
but with instrumentation -
.listen(*channels : String, &block : PQ::Notification -> ) : Nil
Listens for
pg_notify()
calls on each channel inchannels
Yields aPQ::Notification
object withchannel
,payload
, andpid
. - .lock_id : UInt64 | Nil
- .lock_id=(lock_id : UInt64 | Nil)
-
.query(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args)
Same as crystal-db's
DB::QueryMethods#query
but with instrumentation -
.query(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &)
Same as crystal-db's
DB::QueryMethods#:query
but with instrumentation -
.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 -
.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 -
.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 -
.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 -
.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 -
.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 -
.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 -
.rollback
Rollback the current transaction
- .run(&)
-
.scalar(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args)
Same as crystal-db's
DB::QueryMethods#scalar
but with instrumentation - .setup_connection(&block : DB::Connection -> Nil)
-
.transaction(&)
Wrap the block in a database transaction
-
.truncate
Run a SQL
TRUNCATE
on all tables in the database - .verify_connection
Instance Method Summary
-
#exec(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args)
Same as crystal-db's
DB::QueryMethods#exec
but with instrumentation - #publish_query_event(query, args_, args, queryable, &)
-
#query(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args)
Same as crystal-db's
DB::QueryMethods#query
but with instrumentation -
#query(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args, &)
Same as crystal-db's
DB::QueryMethods#:query
but with instrumentation -
#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 -
#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 -
#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 -
#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 -
#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 -
#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 -
#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 -
#scalar(query, *args_, args : Array | Nil = nil, queryable : String | Nil = nil, **named_args)
Same as crystal-db's
DB::QueryMethods#scalar
but with instrumentation
Instance methods inherited from class Object
blank_for_validates_required? : Bool
blank_for_validates_required?
Class Method Detail
Same as crystal-db's DB::QueryMethods#exec
but with instrumentation
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
Same as crystal-db's DB::QueryMethods#query
but with instrumentation
Same as crystal-db's DB::QueryMethods#:query
but with instrumentation
Same as crystal-db's DB::QueryMethods#query_all
but with instrumentation
Same as crystal-db's DB::QueryMethods#:query_all
but with instrumentation
Same as crystal-db's DB::QueryMethods#:query_each
but with instrumentation
Same as crystal-db's DB::QueryMethods#query_one
but with instrumentation
Same as crystal-db's DB::QueryMethods#:query_one
but with instrumentation
Same as crystal-db's DB::QueryMethods#query_one?
but with instrumentation
Same as crystal-db's DB::QueryMethods#:"query_one?"
but with instrumentation
Same as crystal-db's DB::QueryMethods#scalar
but with instrumentation
Wrap the block in a database transaction
AppDatabase.transaction do
# Create, read, update
# Force a rollback with AppDatabase.rollback
end
Instance Method Detail
Same as crystal-db's DB::QueryMethods#exec
but with instrumentation
Same as crystal-db's DB::QueryMethods#query
but with instrumentation
Same as crystal-db's DB::QueryMethods#:query
but with instrumentation
Same as crystal-db's DB::QueryMethods#query_all
but with instrumentation
Same as crystal-db's DB::QueryMethods#:query_all
but with instrumentation
Same as crystal-db's DB::QueryMethods#:query_each
but with instrumentation
Same as crystal-db's DB::QueryMethods#query_one
but with instrumentation
Same as crystal-db's DB::QueryMethods#:query_one
but with instrumentation
Same as crystal-db's DB::QueryMethods#query_one?
but with instrumentation