module Granite::Transactions

Direct including types

Defined in:

granite/transactions.cr

Instance Method Summary

Instance Method Detail

def destroy #

Removes the record from the database. Returns true if successful, false otherwise.


[View source]
def destroy! #

Same as #destroy, but raises Granite::RecordNotDestroyed if unsuccessful.


[View source]
def save(*, validate : Bool = true, skip_timestamps : Bool = false) #

Attempts to save the record to the database, returning true if successful, and false if not. If the save is unsuccessful, #errors will be populated with the errors which caused the save to fail.

NOTE: This method can be used both on new records, and existing records. In the case of new records, it creates the record in the database, otherwise, it updates the record in the database.


[View source]
def save!(*, validate : Bool = true, skip_timestamps : Bool = false) #

Same as #save, but raises Granite::RecordNotSaved if the save is unsuccessful.


[View source]
def set_timestamps(*, to time = Time.local(Granite.settings.default_timezone), mode = :create) #

Sets the record's timestamps(created_at & updated_at) to the current time.


[View source]
def touch(*fields) : Bool #

Updates the updated_at field to the current time, without saving other fields.

Raises error if record hasn't been saved to the database yet.


[View source]
def update(args, skip_timestamps : Bool = false) #

Updates the record with the new data specified by args, with the option to not update timestamps. Returns true if the update is successful, false if it isn't.


[View source]
def update(**args) #

Updates the record with the new data specified by args. Returns true if the update is successful, false if it isn't.


[View source]
def update!(args, skip_timestamps : Bool = false) #

Updates the record with the new data specified by args, with the option to not update timestamps. Raises Granite::RecordNotSaved if the save is unsuccessful.


[View source]
def update!(**args) #

Updates the record with the new data specified by args. Raises Granite::RecordNotSaved if the save is unsuccessful.


[View source]