module Granite::Transactions::ClassMethods
Direct including types
Defined in:
granite/transactions.crInstance Method Summary
-
#clear
Removes all records from a table.
-
#create(args, skip_timestamps : Bool = false)
Creates a new record, and attempts to save it to the database.
-
#create(**args)
Creates a new record, and attempts to save it to the database.
-
#create!(args, skip_timestamps : Bool = false)
Creates a new record, and attempts to save it to the database.
-
#create!(**args)
Creates a new record, and attempts to save it to the database.
-
#import(model_array : Array(self) | Granite::Collection(self), update_on_duplicate : Bool, columns : Array(String), batch_size : Int32 = model_array.size)
Runs an INSERT statement for all records in model_array, with options to update any duplicate records, and provide column names.
-
#import(model_array : Array(self) | Granite::Collection(self), batch_size : Int32 = model_array.size)
Runs an INSERT statement for all records in model_array.
- #import(model_array : Array(self) | Granite::Collection(self), ignore_on_duplicate : Bool, batch_size : Int32 = model_array.size)
Instance Method Detail
Creates a new record, and attempts to save it to the database. Allows saving the record without timestamps. Returns the newly created record.
Creates a new record, and attempts to save it to the database. Returns the newly created record.
NOTE: This method still outputs the new object even when it failed to save
to the database. The only way to determine a failure is to check any errors on
the object, or to use #create!
.
Creates a new record, and attempts to save it to the database. Allows saving
the record without timestamps. Returns the newly created record. Raises
Granite::RecordNotSaved
if the save is unsuccessful.
Creates a new record, and attempts to save it to the database. Returns the
newly created record. Raises Granite::RecordNotSaved
if the save is
unsuccessful.
Runs an INSERT statement for all records in model_array, with options to update any duplicate records, and provide column names.
Runs an INSERT statement for all records in model_array. the array must contain only one model class invalid model records will be skipped