Skip to content

Repository files navigation

Avram

API Documentation Website

Database ORM built for the Lucky Framework written in Crystal. Supporting PostgreSQL 12+ and based off principals of Elixir Ecto and Rails ActiveRecord.

Why Avram?

The name comes from Henriette Avram.

Henriette Davidson Avram (October 7, 1919 – April 22, 2006) was a computer programmer and systems analyst who developed the MARC format (Machine Readable Cataloging), the international data standard for bibliographic and holdings information in libraries.

Installation

Add this to your application's shard.yml:

dependencies:
avram:
github: luckyframework/avram

Usage

require"avram"# Define your databaseclassAppDatabase < Avram::DatabaseendAppDatabase.configure do |settings|
settings.credentials =Avram::Credentials.new(
database:"my_app_development",
username:"postgres",
hostname:"localhost",
password:"password",
port:5432,
)
end# Configure Avram to use your databaseAvram.configure do |settings|
settings.database_to_migrate =AppDatabase# When `true`, allow lazy loading (N+1).# If `false` raise an error if you forget to preload associations
settings.lazy_load_enabled =true
settings.query_cache_enabled =falseend# Create your read-only modelclassPerson < Avram::Modeldefself.database : Avram::Database.class
AppDatabaseend
table :peopledo
column name : String
column age : Int32
column programmer : Bool=trueendend# Insert a new recordPerson::SaveOperation.create!(name:"Henriette Davidson Avram", age:86)
# Query for a record
person =Person::BaseQuery.new.name.ilike("%avram")
person.programmer? #=> true

For more details, read the guides.

Contributing

  1. Fork it ( https://github.com/luckyframework/avram/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make your changes
  4. Run specs crystal spec
  5. Check formatting crystal tool format spec/ src/
  6. Check ameba ./bin/ameba
  7. Commit your changes (git commit -am 'Add some feature')
  8. Push to the branch (git push origin my-new-feature)
  9. Create a new Pull Request

Docker is provided for quick setup and testing. You can run ./script/setup and ./script/test for ease.

Contributors

paulcsmith Paul Smith - Original Creator of Lucky

Made with contrib.rocks.

About

A Crystal database wrapper for reading, writing, and migrating Postgres databases.

Topics

Resources

Code of conduct

Contributing

Stars

183 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages