abstract class PgORM::Base
- PgORM::Base
- ActiveModel::Model
- Reference
- Object
Included Modules
- ActiveModel::Callbacks
- ActiveModel::Validation
- PgORM::Associations
- PgORM::Persistence
- PgORM::Table
- PgORM::Validators
Extended Modules
- PgORM::ChangeReceiver
- PgORM::Query
Defined in:
pg-orm/base.crConstant Summary
-
AM_PARENT_TYPE =
{:type => PgORM::Base} of Nil => Nil
-
TABLES =
[] of String
Constructors
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .new(pull : JSON::PullParser)
- .new(rs : DB::ResultSet)
Class Method Summary
-
.attributes : Array(Symbol)
Returns all attribute keys.
-
.clear
Removes all records from the table
-
.create(**attributes)
Creates the model.
-
.create!(**attributes)
Creates the model.
-
.delete(*ids) : Nil
Deletes one or many records identified by ids from the database.
- .from_rs(rs : DB::ResultSet)
-
.truncate(cascade = true)
Truncate quickly removes all from table.
-
.update(id, args) : Nil
Updates one or many records identified by id in the database.
-
.update(id, **args) : Nil
Updates one or many records identified by id in the database.
Macro Summary
- __customize_orm__
- __nilability_validation__
- default_primary_key(name, autogenerated = true, converter = nil, **tags)
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#apply_defaults
Generate code to apply default values
-
#assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
Assign to mulitple attributes via
HTTP::Params
. -
#assign_attributes(model : PgORM::Base)
Assign to multiple attributes from a model object
-
#assign_attributes
Assign to multiple attributes.
-
#attributes
Returns a
Hash
of all attribute values -
#attributes_tuple
Returns a
NamedTuple
of all attribute values. - #extra_attributes : Hash(String, PgORM::Value)
-
#id
Always returns this record's primary key value, even when the primary key isn't named
#id
-
#id?
Same as
#id
but may returnnil
when the record hasn't been saved instead of raising. -
#persistent_attributes
Returns a
Hash
of all attributes that can be persisted. - #primary_key
- #to_json(json : JSON::Builder)
Macros inherited from module PgORM::Validators
ensure_unique(field, scope = [] of Nil, callback = nil, &transform)
ensure_unique
Macros inherited from module PgORM::Table
__process_table__
__process_table__,
table(name)
table
Instance methods inherited from module PgORM::Persistence
delete
delete,
destroy
destroy,
destroyed=(destroyed : Bool)
destroyed=,
destroyed? : Bool
destroyed?,
persisted?
persisted?,
reload!
reload!,
save(**options)
save,
save!(**options)
save!,
update(**attributes)
update,
update!(**attributes)
update!,
update_fields(**attributes)
update_fields
Macros inherited from module PgORM::Associations
__process_assoc_serialization__
__process_assoc_serialization__,
belongs_to(name, class_name = nil, foreign_key = nil, autosave = nil, dependent = nil)
belongs_to,
has_many(name, class_name = nil, foreign_key = nil, autosave = nil, dependent = nil, serialize = false)
has_many,
has_one(name, class_name = nil, foreign_key = nil, autosave = nil, dependent = nil)
has_one
Constructor Detail
Class Method Detail
Deletes one or many records identified by ids from the database.
User.delete(1)
User.delete(1, 2, 3)
Updates one or many records identified by id in the database.
User.update(1, {name: user})
User.update([1, 2, 3], {group_id: 2})
Updates one or many records identified by id in the database.
User.update(1, {name: user})
User.update([1, 2, 3], {group_id: 2})
Macro Detail
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Assign to mulitple attributes via HTTP::Params
.
Always returns this record's primary key value, even when the primary key
isn't named #id