Documentation ¶
Overview ¶
Package dbmanager Provides a postgres database manager using sqlx. It uses maps to create manage an save data in postgres database
Index ¶
- Variables
- type DBManager
- func (database *DBManager) Connect(dbName string, dbUser string, dbPassword string) error
- func (database *DBManager) ConnectURL(url string) error
- func (database *DBManager) CreateTable(tableName string, fields []Field) error
- func (database *DBManager) DeleteAllRows(tableName string) error
- func (database *DBManager) DeleteRowBy(tableName string, element Value) error
- func (database *DBManager) DropTable(tableName string) error
- func (database *DBManager) FilerRowsBy(tableName string, filterBy Value, orderBy ...string) ([]Value, error)
- func (database *DBManager) GetAllRows(tableName string) ([]Value, error)
- func (database *DBManager) InsertElement(tableName string, element Value) error
- func (database *DBManager) PagedQuery(tableName string, pageInfo Value) ([]Value, error)
- func (database *DBManager) SearchRowsBy(tableName string, filterBy Value, orderBy ...string) ([]Value, error)
- func (database *DBManager) TableExists(tableName string) bool
- func (database *DBManager) UpdateRowBy(tableName string, filter Value, elem Value) error
- type Field
- type Value
Constants ¶
This section is empty.
Variables ¶
var SCHEMA_MANAGER = "schema_manager_db"
Functions ¶
This section is empty.
Types ¶
type DBManager ¶
type DBManager struct {
// contains filtered or unexported fields
}
DBManager - Struct containig DB information
func (*DBManager) Connect ¶
Connect - connect to the database specified
PARAMS: dbName: name of the database to connect to dbUser: username of the postgres user dbPassword: password of the postgres user returns: error if any
func (*DBManager) ConnectURL ¶ added in v0.2.2
ConnectURL - connect to the database specified
PARAMS: url: name of the database to connect to returns: error if any
func (*DBManager) CreateTable ¶
CreateTable - creates a table with provided name and fields
PARAMS: tableName: name of the table to be created fields: slice of fields with field name and type returns: error if any
func (*DBManager) DeleteAllRows ¶ added in v0.2.0
DeleteAllRows - deletes all the elements from a table
PARAMS: tableName: name of the table where to delete returns: error if any
func (*DBManager) DeleteRowBy ¶ added in v0.2.0
DeleteRowBy - Delete element from table
PARAMS: tableName: name of the table where to delete element: a Value(key-value) map of the column(s) to search by returns: error if any
func (*DBManager) DropTable ¶
DropTable - Deletes table from system
PARAMS: tableName: name of the table to search for returns: error if any
func (*DBManager) FilerRowsBy ¶ added in v0.2.0
func (database *DBManager) FilerRowsBy(tableName string, filterBy Value, orderBy ...string) ([]Value, error)
FilerRowsBy - Search by column containing exactly each column value
PARAMS: tableName: name of the table where to search filterBy: a Value(key-value) map of the column to search by orderBy: optional string of column name to sort by returns: Value slice of each row, error if any
func (*DBManager) GetAllRows ¶ added in v0.2.0
GetAllRows - returns all the rows of the table
PARAMS: tableName: name of the table to be returned returns: slice of Value, error if any
func (*DBManager) InsertElement ¶
InsertElement - inserts element in a table
PARAMS: tablename: name of the table where to instert element: Value(Key-Value map) of the element to insert returns: error if any
func (*DBManager) PagedQuery ¶ added in v0.2.6
PagedQuery - Search by column containing part of the string
PARAMS: tableName: name of the table where to search pageInfo: a map of pageNumber, pageSize returns: Value slice of each row, error if any
func (*DBManager) SearchRowsBy ¶ added in v0.2.0
func (database *DBManager) SearchRowsBy(tableName string, filterBy Value, orderBy ...string) ([]Value, error)
SearchRowsBy - Search by column containing part of the string
PARAMS: tableName: name of the table where to search filterBy: a Value(key-value) map of the column to search by orderBy: optional string of column name to sort by returns: Value slice of each row, error if any
func (*DBManager) TableExists ¶ added in v0.1.2
TableExists - Check if table exists PARAMS:
tableName: name of the table to search for returns: True if the table exists, False if not
func (*DBManager) UpdateRowBy ¶ added in v0.2.0
UpdateRowBy - update all matching rows from a certain table PARAMS:
tablename: name of the table to update filter: filter to search row to change elem: map of the column(s) to update returns: error if any