module Marten::DB::Model::Persistence
Direct including types
Defined in:
marten/db/model/persistence.crInstance Method Summary
-
#delete(using : Nil | String | Symbol = nil)
Deletes the model instance.
-
#deleted?
Returns a boolean indicating if the record was deleted or not.
-
#new_record?
Returns a boolean indicating if the record doesn't exist in the database yet.
-
#persisted?
Returns a boolean indicating if the record is persisted in the database.
-
#reload
Reloads the model instance.
-
#save(using : Nil | String | Symbol = nil, validate : Bool = true) : Bool
Saves the model instance.
-
#save!(using : Nil | String | Symbol = nil, validate : Bool = true) : Bool
Saves the model instance.
-
#update(values : Hash | NamedTuple)
Updates the model instance.
-
#update(**values)
Updates the model instance.
-
#update!(values : Hash | NamedTuple)
Updates the model instance.
-
#update!(**values)
Updates the model instance.
Instance Method Detail
Deletes the model instance.
This methods deletes the model instance by complying to the deletion rules defined as part of the relation
fields if applicable (on_delete
option on many to one or one to one fields). It returns the number of rows
that were deleted as part of the record deletion.
Returns a boolean indicating if the record was deleted or not.
This method returns true
if the model instance was deleted previously. Otherwise it returns false
in any
other cases.
Returns a boolean indicating if the record doesn't exist in the database yet.
This methods returns true
if the model instance hasn't been saved and doesn't exist in the database yet. In
any other cases it returns false
.
Returns a boolean indicating if the record is persisted in the database.
This method returns true
if the record at hand exists in the database. Otherwise (if it's a new record or if
it was deleted previously), the method returns false
.
Reloads the model instance.
This methods retrieves the record at the database level and updates the current model instance with the new values.
Saves the model instance.
If the model instance is new, a new record is created in the DB ; otherwise the existing record is updated.
This method will return true
if the model instance is valid and was created / updated successfully.
Otherwise it will return false
if the model instance validation failed.
Saves the model instance.
If the model instance is new, a new record is created in the DB ; otherwise the existing record is updated.
This method will return true
if the model instance is valid and was created / updated successfully.
Otherwise it will raise a Marten::DB::Errors::InvalidRecord
exception if the model instance validation
failed.
Updates the model instance.
This method updates the passed field values and then saves the record. This method returns true
if the model
instance is valid and was created / updated successfully. Otherwise it returns false
if the model instance
validation fails.
Updates the model instance.
This method updates the passed field values and then saves the record. This method returns true
if the model
instance is valid and was created / updated successfully. Otherwise it returns false
if the model instance
validation fails.
Updates the model instance.
This method updates the passed field values and then saves the record. This method returns true
if the model
instance is valid and was created / updated successfully. Otherwise it raises a
Marten::DB::Errors::InvalidRecord
exception if the model instance validation fails.
Updates the model instance.
This method updates the passed field values and then saves the record. This method returns true
if the model
instance is valid and was created / updated successfully. Otherwise it raises a
Marten::DB::Errors::InvalidRecord
exception if the model instance validation fails.