Setup
Setup: As new project
Setup: In existing project
$ crystal init app <yourappname>
$ cd <yourappname>In `shard.yml`
Add your dependency in the dependencies list of your shard.yml
Then download the library:
$ shards installIn your source code
Assuming your main entry point of your application is src/main.cr , you can require and initialize Clear:
Step by Step
require "clear"load the source code of Clear and provide everything needed to use the library.Clear::SQL.initprepare a certain number of connection to your database. The URL is a convention used to connect to the database, and follow this schema:
More information about the URL notation can be found here
connection_pool_size: 5is optional but offers the possibility to concurrent fibers to run query at the same time. It's useful if you use an event-driven server, like Kemal.
Installation customization
You may want to install a smaller version of Clear by calling :
This will add clear without the build-in CLI and without some extensions (jsonb, bcrypt etc...).
Last updated