dbmanager

package module
v0.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

README

PG_DBManager-Go GoDoc

PostGres database manager using sqlx in golang

Documentation

Overview

Package dbmanager Provides a postgres database manager using sqlx. It uses maps to create manage an save data in postgres database

Index

Constants

This section is empty.

Variables

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

func (database *DBManager) Connect(dbName string, dbUser string, dbPassword string) error

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

func (database *DBManager) ConnectURL(url string) error

ConnectURL - connect to the database specified

PARAMS:
url: name of the database to connect to
	returns: error if any

func (*DBManager) CreateTable

func (database *DBManager) CreateTable(tableName string, fields []Field) error

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

func (database *DBManager) DeleteAllRows(tableName string) error

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

func (database *DBManager) DeleteRowBy(tableName string, element Value) error

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

func (database *DBManager) DropTable(tableName string) error

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

func (database *DBManager) GetAllRows(tableName string) ([]Value, error)

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

func (database *DBManager) InsertElement(tableName string, element Value) error

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

func (database *DBManager) PagedQuery(tableName string, pageInfo Value) ([]Value, error)

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

func (database *DBManager) TableExists(tableName string) bool

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

func (database *DBManager) UpdateRowBy(tableName string, filter Value, elem Value) error

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

type Field

type Field struct {
	Name string
	Type string
}

Field - Struct of a database field, defines name and type of column

type Value

type Value map[string]interface{}

Value - Value extracted from database, map with colum as keys

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL