db

package
v0.0.0-...-d8b76b4 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LocalConn *sqlx.DB
View Source
var RemoteConn *sqlx.DB

Functions

func CheckLocalDB

func CheckLocalDB() bool

func ColumnExists

func ColumnExists(tableName, columnName, driverName string) bool

func CompareBehaviors

func CompareBehaviors(behavior1 Behavior, behavior2 Behavior) bool

func CompareKeyMappings

func CompareKeyMappings(keyMapping1 KeyMapping, keyMapping2 KeyMapping) bool

func ComparePathMappings

func ComparePathMappings(pathMapping1 PathMapping, pathMapping2 PathMapping) bool

func Create

func Create(tableName string, data map[string]string, driverName string) error

Create inserts data in the database returning an error if it occurs

func CreateTables

func CreateTables() (err error)

func Delete

func Delete(tableName string, filters map[string]string, driverName string) error

Delete removes a data from database, using the provided filters, returning an error if it occurs

func FactoryReset

func FactoryReset() (err error)

func LocalDB

func LocalDB() *sqlx.DB

LocalDB will connect to a local SQLITE database which stores GREST's configuration.

func Read

func Read(tableName string, filters map[string]string, driverName string) (result []map[string]string, err error)

Read returns an array of maps containing the results retrieved from database and an error, if it occurs

func RemoteDB

func RemoteDB() *sqlx.DB

RemoteDB is the connection with the user's database (MySQL) This func needs e host, port and database to create the connection...

func TableExists

func TableExists(tableName string, driverName string) bool

func ToMapSlice

func ToMapSlice(unparsedData []map[string]interface{}) (parsedData []map[string]string)

func Update

func Update(tableName string, filters map[string]string, data map[string]string, driverName string) error

Update changes data in the database. using the provided filters and data maps, returning an error if it occurs

Types

type Behavior

type Behavior struct {
	PathMapping PathMapping
	KeyMappings []KeyMapping
}

func GetBehaviors

func GetBehaviors() ([]Behavior, error)

GetBehaviors return an array of behaviors present in the database

type ColumnDoesNotExistsError

type ColumnDoesNotExistsError struct {
	// contains filtered or unexported fields
}

func (ColumnDoesNotExistsError) Error

func (c ColumnDoesNotExistsError) Error() string

type KeyMapping

type KeyMapping struct {
	Key    string
	Column string
}

type PathMapping

type PathMapping struct {
	Path  string
	Table string
}

type TableDoesNotExistsError

type TableDoesNotExistsError struct {
	// contains filtered or unexported fields
}

func (TableDoesNotExistsError) Error

func (t TableDoesNotExistsError) Error() string

Jump to

Keyboard shortcuts

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