Project

datoki

0.0
No commit activity in last 3 years
No release in over 3 years
My way of dealing with postgresql 9.3+ databases.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

> 1.0
> 1.5
> 0.9

Runtime

>= 0.17
> 4.12
 Project Readme

Datoki

A Ruby gem that is part abstraction layer, part validator... for managing data in PostgreSQL.

Installation

gem 'datoki'

Usage

  # === Set it up: =======================
  require 'datoki'
  require 'sequel'
  DB = Sequel.connect ENV['DATABASE_URL']
  DB.cache_schema = false
  Datoki.db DB
  # ======================================

  class Computer
    include Datoki

    field(:id)   { primary_key }
    field(:name) { varchar }
    field(:desc) { text nil, 1, 955 }

    on :create_or_update? do

      on :create? do
        clean :name, :desc
      end

      on :update? do

        clean :name, :desc

        on :special? do
          skip :db
          # do special processing
        end
      end

    end # === :create_or_update?


  end # === class

NOTE:

  1. Raises an error if a mismatch between field definition and schema. Example: :allow_null != field[:allow][:null]