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

Overview

Converts between the SQLite3 TEXT type and Crystal objects with #to_json and .from_json methods (e.g. JSON::Serializable). See Field to read about of how to apply converters.

CREATE TABLE users (
  meta  TEXT  NOT NULL  DEFAULT '{"foo":"bar"}'
);
require "onyx-sql/converters/sqlite3/json"

class User
  include Onyx::SQL::Model

  struct Meta
    include JSON::Serilalizable
    property foo : String
  end

  schema do
    type meta : Meta, converter: SQLite3::JSON(Meta)
  end
end

Defined in:

onyx-sql/converters/sqlite3/json.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(values : Enumerable(T)) #

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

[View source]