abstract class Granite::Adapter::Base

Overview

The Base Adapter specifies the interface that will be used by the model objects to perform actions against a specific database. Each adapter needs to implement these methods.

Direct Known Subclasses

Defined in:

adapter/base.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String, url : String) #

[View source]

Instance Method Detail

abstract def clear(table_name : String) #

remove all rows from a table and reset the counter on the id.


[View source]
def database : DB::Database #

[View source]
abstract def delete(table_name : String, primary_name : String, value) #

This will delete a row from the database.


[View source]
def exists?(table_name : String, criteria : String, params = [] of Granite::Columns::Type) : Bool #

Returns true if a record exists that matches criteria, otherwise false.


[View source]
abstract def import(table_name : String, primary_name : String, auto : Bool, fields, model_array, **options) #

This will insert an array of models as one insert statement


[View source]
abstract def insert(table_name : String, fields, params, lastval) : Int64 #

This will insert a row in the database and return the id generated.


[View source]
def log(query : String, elapsed_time : Time::Span, params = [] of String) : Nil #

[View source]
def name : String #

[View source]
def open(&) #

[View source]
def select(query : Granite::Select::Container, clause = "", params = [] of DB::Any, &) #

select performs a query against a table. The query object contains table_name, fields (configured using the sql_mapping directive in your model), and an optional raw query string. The clause and params is the query and params that is passed in via .all() method


[View source]
abstract def update(table_name : String, primary_name : String, fields, params) #

This will update a row in the database.


[View source]
def url : String #

[View source]