struct Jennifer::Record

Overview

General data structure for the raw data retrieved for the DB.

Dynamically generates getters using .method_missing. If class T is passed as an argument - return value is automatically casted to it.

Jennifer::Query["users"].first.name(String)

Defined in:

jennifer/adapter/record.cr

Constructors

Instance Method Summary

Macro Summary

Constructor Detail

def self.new(attributes : Hash(String, DBAny)) #

[View source]
def self.new #

[View source]

Instance Method Detail

def [](name : Symbol | String) #

Alias for #attribute.


[View source]
def attribute(name : String | Symbol, type : T.class) : T forall T #

Returns casted value of attribute name to the type type.


[View source]
def attribute(name : String) #

Returns value by attribute name.


[View source]
def attribute(name : Symbol) #

Returns value by attribute name.


[View source]
def attributes : Hash(String, Array(Char) | Array(Float32) | Array(Float64) | Array(Int16) | Array(Int32) | Array(Int64) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | Time::Span | UInt32 | UUID | Nil) #

[View source]
def fields #

Returns names of fields.


[View source]
def inspect(io) : Nil #

Returns a string containing a human-readable representation of object.


[View source]
def to_json(only : Array(String)? = nil, except : Array(String)? = nil, &) #

Returns a JSON string representing data set.

For more details see Resource#to_json.


[View source]
def to_json(json : JSON::Builder) #

[View source]
def to_json(json : JSON::Builder, only : Array(String)? = nil, except : Array(String)? = nil, &) #

[View source]
def to_json(only : Array(String)? = nil, except : Array(String)? = nil) #

[View source]

Macro Detail

macro method_missing(call) #

[View source]