module Granite::Transactions::ClassMethods

Direct including types

Defined in:

granite/transactions.cr

Instance Method Summary

Instance Method Detail

def clear #

Removes all records from a table.


[View source]
def 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.


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

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


[View source]
def 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.


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

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.


[View source]
def 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.


[View source]
def 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


[View source]
def import(model_array : Array(self) | Granite::Collection(self), ignore_on_duplicate : Bool, batch_size : Int32 = model_array.size) #

[View source]