Databases with SearchLight.jl
SearchLight.jl
is the complete ORM solution in Genie Framework, supporting Postgres, MySQL and SQLite (ODBC and JDBC support coming soon). SearchLight offers a complete range of features, that go beyond query generation, including database schema versioning through migrations, model validators, data serializers, model relationships, transactions support and much more. SearchLight greatly simplifies the task of working with databases through its portable, concise and readable Julia API.
Base.@kwdef mutable struct User <: AbstractModel
id::DbId = DbId()
username::String = ""
password::String = ""
end
Validation.validator(::Type{User}) = ModelValidator([
ValidationRule(:username, UsersValidator.not_empty),
ValidationRule(:username, UsersValidator.unique),
ValidationRule(:password, UsersValidator.not_empty)
])
function register()
User(username = params(:username),
password = params(:password) |> hash_password,
name = params(:name),
email = params(:email)
) |> save!
end
Configuration
You can get the most out of Genie by pairing it with its seamless ORM layer, SearchLight. As a native Julia ORM, it provides excellent support for working with relational databases. The Genie + SearchLight combo can be used to productively develop CRUD (Create-Read-Update-Delete) apps in which where resources are created, read, updated, and deleted.