From eaddae7d71d52536453ea2d94777854f1b057f83 Mon Sep 17 00:00:00 2001 From: Jamie Gaskins Date: Tue, 27 Oct 2020 11:55:06 -0400 Subject: [PATCH] Add docs for DB::Database#setup_connection (#139) --- src/db/database.cr | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/db/database.cr b/src/db/database.cr index 3eb70cb..b22e381 100644 --- a/src/db/database.cr +++ b/src/db/database.cr @@ -61,6 +61,15 @@ module DB } end + # Run the specified block every time a new connection is established, yielding the new connection + # to the block. + # + # ``` + # db = DB.open(DB_URL) + # db.setup_connection do |connection| + # connection.exec "SET TIME ZONE 'America/New_York'" + # end + # ``` def setup_connection(&proc : Connection -> Nil) @setup_connection = proc @pool.each_resource do |conn|