15.1 DB init hooks

Sometimes you need to do some configurations before using DB, Artanis provide an API for that, you should put it to ENTRY file before run the server.

For example, assuming you’re using MySQL/MariaDB, and you need to configure it to UTF-8, you should add these lines to you ENTRY file. Or if you’re using minimal mode without application folder, just put it before running the server.

(run-when-DB-init!
 (lambda (conn)
   (DB-query conn "set names utf8;")))

NOTE: Don’t forget ‘!’ here, it implies the side-effects in Scheme!