Jennifer

What is Jennifer?

Jennifer is an ActiveRecord pattern for Crystal with great query DSL and migration mechanism.

circle-info

Installing Jennifer for Maze

Generate a normal maze app

maze new {project}

Update your project shard.yml

Add this to your application's

# Add the following dependencies
jennifer:
  github: imdrasil/jennifer.cr

sam:
  github: imdrasil/sam.cr

Choose one of existing adapters for your db: mysqlarrow-up-right or postgresarrow-up-right.

Then in the console

Setup your database information

Create a jennifer.cr under the /config directory

circle-info

Note that we pass the MAZE_ENV to Jennifer::Config.read this will allow Jennifer to use the correct database settings for the environment.

Create a sam.cr in {project/src}

Jennifer uses Sam for running tasks pertinent to ORM operations. Sam is a Make-like utility which allows to specify tasks like Ruby's Rake do using plain Crystal. For how to use Samarrow-up-right visit the Github repository https://github.com/imdrasil/sam.crarrow-up-right

Edit your src/{project}.cr file

This should be done before you load your application configurations (or at least models). With Maze this is very easy. Also the order is very important the adapter should come before Jennifer.

You're all set with the configuration. Next using Jennifer Migrations and Models.

Last updated