module

Granite::Transactions::ClassMethods

Instance methods

clear

Removes all records from a table.

Source
create(args, skip_timestamps : Bool = false)

Creates a new record, and attempts to save it to the database. Allows saving the record without timestamps. Returns the newly created record.

Source
create

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!.

Source
create!(args, skip_timestamps : Bool = false)

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.

Source
create!

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.

Source
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.

Source
import(model_array : Array(self) | Granite::Collection(self), batch_size : Int32 = model_array.size)

Runs an INSERT statement for all records in model_array. the array must contain only one model class invalid model records will be skipped

Source
import(model_array : Array(self) | Granite::Collection(self), ignore_on_duplicate : Bool, batch_size : Int32 = model_array.size)
Source