module Onyx::SQL::Converters::SQLite3::EnumText(T)

Overview

Converts between the SQLite3 TEXT type and Crystal Enums. See Field to read about of how to apply converters.

See the comparison of enum converters at Converters::SQLite3::EnumInt.

CREATE TABLE users (
  permission  TEXT  NOT NULL  DEFAULT 'create_posts',
  permissions TEXT  NOT NULL  DEFAULT '{create_posts,edit_posts}'
);
require "onyx-sql/converters/sqlite3"

class User
  include Onyx::SQL::Model

  enum Permission
    CreatePosts
    EditPosts
  end

  schema do
    type permission : Permission, converter: SQLite3::EnumText(User::Permission))]
    type permissions : Array(Permission), converter: SQLite3::EnumText(User::Permission)
  end
end

Defined in:

onyx-sql/converters/sqlite3/enum_text.cr

Class Method Summary

Class Method Detail

def self.from_rs(rs) : T? #

[View source]
def self.from_rs_array(rs) : ::Array(T)? #

[View source]
def self.to_db(value : T) #

[View source]
def self.to_db(values : Enumerable(T)) #

[View source]