Documentation
¶
Index ¶
- Constants
- type DBColumn
- func (cd *DBColumn) GetDBType() string
- func (cd *DBColumn) GetLength() int64
- func (cd *DBColumn) GetName() string
- func (cd *DBColumn) GetNullable() bool
- func (cd *DBColumn) GetOrdinal() int
- func (cd *DBColumn) GetPrecision() int64
- func (cd *DBColumn) GetScale() int64
- func (cd *DBColumn) GetType() reflect.Type
- func (dc *DBColumn) MarshalJSON() ([]byte, error)
- type DBCommandInterface
- type DBConnectionInterface
- type DBRow
- func (dr *DBRow) GetItemByIndex(index int) (interface{}, error)
- func (dr *DBRow) GetItemByName(columnName string) (interface{}, error)
- func (dr *DBRow) MarshalJSON() ([]byte, error)
- func (dr *DBRow) SetItemByIndex(index int, value interface{}) error
- func (dr *DBRow) SetItemByName(columnName string, value interface{}) error
- type DBTable
- type DataFetcher
- type DataReader
- type DataWriter
- type ExistenceChecker
- type MockConn
- type MockConnector
- type MockDriver
- func (d *MockDriver) CleanErrorMessage()
- func (d *MockDriver) Open(name string) (driver.Conn, error)
- func (d *MockDriver) OpenConnector(name string) (driver.Connector, error)
- func (d *MockDriver) SetCloseErrorMessage(message string)
- func (d *MockDriver) SetConnectorErrorMessage(message string)
- func (d *MockDriver) SetPingerErrorMessage(message string)
- type Repository
Constants ¶
View Source
const (
NIL_CONNECTION = "connection is nil"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBColumn ¶
type DBColumn struct { Table *DBTable // contains filtered or unexported fields }
func CreateNewDBColumn ¶
func CreateNewDBColumnFromColumnType ¶
func CreateNewDBColumnFromColumnType(ct sql.ColumnType, ordinal int) DBColumn
func (*DBColumn) GetNullable ¶
func (*DBColumn) GetOrdinal ¶
func (*DBColumn) GetPrecision ¶
func (*DBColumn) MarshalJSON ¶
type DBCommandInterface ¶
type DBCommandInterface interface { Execute(query string, params ...interface{}) (*sql.Result, error) Query(query string, params ...interface{}) (*DBTable, error) QueryFirst(query string, params ...interface{}) (*DBRow, error) }
func CreateNewDBCommand ¶
func CreateNewDBCommand(con DBConnectionInterface) (DBCommandInterface, error)
type DBConnectionInterface ¶
type DBConnectionInterface interface { Open() error Close() error // contains filtered or unexported methods }
func CreateNewDBConnection ¶
func CreateNewDBConnection(driver string, dsn string) (DBConnectionInterface, error)
type DBRow ¶
type DBRow struct { Table *DBTable // contains filtered or unexported fields }
func (*DBRow) GetItemByIndex ¶
func (*DBRow) GetItemByName ¶
func (*DBRow) MarshalJSON ¶
func (*DBRow) SetItemByIndex ¶
func (*DBRow) SetItemByName ¶
type DBTable ¶
type DBTable struct {
// contains filtered or unexported fields
}
func CreateNewDBTable ¶
func CreateNewDBTable() DBTable
func (*DBTable) AddDBColumn ¶
func (*DBTable) CreateNewDBRow ¶
func (*DBTable) GetColumns ¶
func (*DBTable) MarshalJSON ¶
type DataFetcher ¶ added in v0.1.1
type DataFetcher[T any] interface { // Fetch fetches the entity records by the given limit and offset. Fetch(limit, offset int) ([]T, error) }
DataFetcher is an interface used to fetch entity records by given limit and offset values.
type DataReader ¶ added in v0.1.1
type DataReader[T any, K any] interface { // GetById gets the entity record by the id value. // For composite primary keys, a struct can be used as a parameter. GetById(id K) (T, error) // Retrieve retrieves all the records of the entity from the database. Retrieve() ([]T, error) }
DataReader is an interface used to read data from the database.
type DataWriter ¶ added in v0.1.1
type DataWriter[T any, K any] interface { // Insert inserts a new record into the database and returns the primary key value. // For composite primary keys, a struct can be used as a result. Insert(entity T) (K, error) // Update updates the given entity by the id value. // For composite primary keys, a struct can be used as a parameter. Update(id K, entity T) (bool, error) // Delete deletes the database entity record by the id value. // For composite primary keys, a struct can be used as a parameter. Delete(id K) (bool, error) }
DataWriter is an interface used to write data to the database.
type ExistenceChecker ¶ added in v0.1.1
type ExistenceChecker[T any] interface { // CheckExistence checks the existence of a record by the id column. // For composite primary keys, a struct can be used as a parameter. CheckExistence(id T) (bool, error) }
ExistenceChecker is an interface used to check the existence of an entity.
type MockConnector ¶
type MockConnector struct {
// contains filtered or unexported fields
}
type MockDriver ¶
type MockDriver struct {
// contains filtered or unexported fields
}
func (*MockDriver) CleanErrorMessage ¶
func (d *MockDriver) CleanErrorMessage()
func (*MockDriver) OpenConnector ¶
func (d *MockDriver) OpenConnector(name string) (driver.Connector, error)
Fake-it
func (*MockDriver) SetCloseErrorMessage ¶
func (d *MockDriver) SetCloseErrorMessage(message string)
func (*MockDriver) SetConnectorErrorMessage ¶
func (d *MockDriver) SetConnectorErrorMessage(message string)
func (*MockDriver) SetPingerErrorMessage ¶
func (d *MockDriver) SetPingerErrorMessage(message string)
type Repository ¶ added in v0.1.1
type Repository[T any, K any] interface { DataReader[T, K] DataFetcher[T] ExistenceChecker[K] DataWriter[T, K] }
Repository is an interface used for general database operations.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.