onyxframework / sql

A delightful SQL ORM ☺️
https://api.onyxframework.com/sql
MIT License
91 stars 7 forks source link

Move existing Query, Schema and Repository under SQL module #53

Closed vladfaust closed 6 years ago

vladfaust commented 6 years ago

I want to make Core as much abstract as possible, allowing to rely on paradigms other than SQL, e.g. Tarantool. Existing architecture is suitable for SQL back-ends only.

require "core"

struct User
  include Core::SQL::Schema
  include Core::SQL::Query
  include Core::Validation

  schema :users do
    primary_key :id
    field :name, String
  end
end

repo = Core::SQL::Repository.new(db)
user = repo.query(User.where("id > ?", 42)

And with community shard "core-tarantool":

require "core-tarantool"

struct User
  include Core::Tarantool::Schema
  include Core::Validation

  schema :users do
    primary_index :id
    field :name, String
  end
end

repo = Core::Tarantool::Repository.new(tnt)
user = repo.select(User, :id, :>, 42) # Select User where id > 42
vladfaust commented 6 years ago

I think SQL-only Core is alright.