Avram::Database
Class methods
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
Runs a SQL VACUUM command. Optionally specify a model to run the vacuum against that table.
AppDatabase.vacuum
AppDatabase.vacuum(User)
Creates a lock on the table in mode
AppDatabase.with_lock_on(User, mode: :row_exclusive) do
user = UserQuery.new.id(1).for_update.first
SaveUser.update!(user, name: "New Name")
end
Instance methods
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