database

package module
v0.0.0-...-4fded36 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseConnection

func CloseConnection(dbEngine ITransactionSQL)

func ConvertJsonToQueryMap

func ConvertJsonToQueryMap(dir string) error

func CreateSQLTransaction

func CreateSQLTransaction(dbEngine ITransactionSQL, dbFunction func(tx *sql.Tx) error) error

func Query

func Query(path string, input ...interface{}) (string, error)

func WriteToDB

func WriteToDB(tx ITransaction, path string, input ...interface{}) (int64, error)

Types

type IColumnMatcher

type IColumnMatcher interface {
	ColumnMatcher(columnName string) interface{}
	GetAllColumn() []interface{}
}

type ITransaction

type ITransaction interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
}

type ITransactionSQL

type ITransactionSQL interface {
	Begin() (*sql.Tx, error)
	Ping() error
	Close() error
	Query(query string, args ...interface{}) (*sql.Rows, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
}

type MysqlDatabaseAccess

type MysqlDatabaseAccess struct {
	Username string
	Password string
	Protocol string
	Address  string
	DBName   string
}

func (MysqlDatabaseAccess) ConnectDatabase

func (mda MysqlDatabaseAccess) ConnectDatabase() (ITransactionSQL, error)

type Notification

type Notification struct {
	Id      int    `json:"id"`
	UserId  string `json:"user_id"`
	TopicId int    `json:"topic_id"`
	Message string `json:"message"`
	IsRead  bool   `json:"is_read"`
}

-------- NOTIFICATION MODEL FUNCTION --------- //

func (*Notification) ColumnMatcher

func (n *Notification) ColumnMatcher(column string) interface{}

func (*Notification) Get

func (n *Notification) Get(tx ITransaction) error

func (*Notification) GetAllColumn

func (n *Notification) GetAllColumn() []interface{}

func (Notification) Insert

func (n Notification) Insert(tx ITransaction) (int64, error)

func (Notification) InsertFormat

func (n Notification) InsertFormat() string

func (*Notification) Scan

func (n *Notification) Scan(rows RowsScan, selectRows []string) error

type Notifications

type Notifications []Notification

func (Notifications) ComposeIdBulkFormat

func (n Notifications) ComposeIdBulkFormat() string

func (Notifications) ComposeInputBulkFormat

func (n Notifications) ComposeInputBulkFormat() string

func (Notifications) Delete

func (n Notifications) Delete(tx ITransaction) (int64, error)

func (*Notifications) Get

func (n *Notifications) Get(tx ITransaction, selectColumn []string, wherePairs [][]string) error

func (Notifications) Insert

func (n Notifications) Insert(tx ITransaction) (int64, error)

func (Notifications) InsertFormat

func (n Notifications) InsertFormat() string

func (*Notifications) Scan

func (n *Notifications) Scan(rows RowsScan, selectColumn []string) error

func (Notifications) UpdateReadNotification

func (n Notifications) UpdateReadNotification(tx ITransaction) (int64, error)

type QueryMap

type QueryMap map[string]map[string]interface{}

func (QueryMap) GetQuery

func (qm QueryMap) GetQuery(path string) (string, error)

type RowsScan

type RowsScan interface {
	Next() bool
	Scan(...interface{}) error
	Close() error
	Err() error
}

func ReadFromDB

func ReadFromDB(tx ITransaction, path string, selectionInterface ...interface{}) (RowsScan, error)

*

Create an interface after path, currently can be inserted with
selectColumn []string, whereColumn [][]string, afterWhere[][]string
must be inserted in that order

type Subscriber

type Subscriber struct {
	Id      int    `json:"id"`
	TopicId int    `json:"topic_id"`
	UserId  string `json:"user_id"`
}

------- SUBSCRIBER MODEL FUNCTION --------- //

func (*Subscriber) ColumnMatcher

func (s *Subscriber) ColumnMatcher(columnName string) interface{}

func (Subscriber) Delete

func (s Subscriber) Delete(tx ITransaction) (int64, error)

func (Subscriber) DeleteFormat

func (s Subscriber) DeleteFormat() string

func (*Subscriber) GetAllColumn

func (s *Subscriber) GetAllColumn() []interface{}

func (Subscriber) Insert

func (s Subscriber) Insert(tx ITransaction) (int64, error)

func (Subscriber) InsertFormat

func (s Subscriber) InsertFormat() string

type Subscribers

type Subscribers []Subscriber

func (*Subscribers) Get

func (s *Subscribers) Get(tx ITransaction, selectColumn []string, wherePairs [][]string) error

func (*Subscribers) Scan

func (s *Subscribers) Scan(rows RowsScan, selectColumn []string) error

type Topic

type Topic struct {
	Id     int    `json:"id"`
	UserId string `json:"user_id"`
	Title  string `json:"title"`
	Desc   string `json:"description`
}

------- TOPIC MODEL FUNCTION --------- //

func (*Topic) ColumnMatcher

func (t *Topic) ColumnMatcher(column string) interface{}

func (Topic) Delete

func (t Topic) Delete(tx ITransaction) (int64, error)

func (*Topic) GetAllColumn

func (t *Topic) GetAllColumn() []interface{}

func (Topic) Insert

func (t Topic) Insert(tx ITransaction) (int64, error)

func (Topic) InsertFormat

func (t Topic) InsertFormat() string

func (Topic) Update

func (t Topic) Update(tx ITransaction) (int64, error)

func (Topic) UpdateFormat

func (t Topic) UpdateFormat() string

type Topics

type Topics []Topic

func (*Topics) Get

func (t *Topics) Get(tx ITransaction, selectColumn []string, wherePairs [][]string, afterWhere [][]string) error

func (Topics) Insert

func (t Topics) Insert(tx ITransaction) (int64, error)

func (Topics) InsertFormat

func (t Topics) InsertFormat() string

func (*Topics) Scan

func (t *Topics) Scan(rows RowsScan, selectColumn []string) error

type UserProfile

type UserProfile struct {
	Email    string `json:"email"`
	Id       string `json:"id"`
	Password string `json:"password"`
	Token    string `json:"token"`
}

------- USER MODEL FUNCTION --------- //

func (*UserProfile) ColumnMatcher

func (up *UserProfile) ColumnMatcher(columnName string) interface{}

func (UserProfile) Delete

func (up UserProfile) Delete(tx ITransaction) (int64, error)

func (UserProfile) DeleteFormat

func (up UserProfile) DeleteFormat() string

func (*UserProfile) Find

func (up *UserProfile) Find(tx ITransaction, selectColumn []string, wherePairs [][]string) error

func (*UserProfile) Get

func (up *UserProfile) Get(tx ITransaction) error

func (*UserProfile) GetAllColumn

func (up *UserProfile) GetAllColumn() []interface{}

func (UserProfile) GetFilledKey

func (up UserProfile) GetFilledKey() []string

func (UserProfile) Insert

func (up UserProfile) Insert(tx ITransaction) (int64, error)

func (UserProfile) InsertFormat

func (up UserProfile) InsertFormat() string

func (*UserProfile) Scan

func (up *UserProfile) Scan(rows RowsScan, selectRows []string) error

func (UserProfile) ToStringJSON

func (up UserProfile) ToStringJSON() string

func (UserProfile) Update

func (up UserProfile) Update(tx ITransaction, updateables []string) (int64, error)

func (UserProfile) UpdateFormat

func (up UserProfile) UpdateFormat(updateables []string) string

type UserProfiles

type UserProfiles []UserProfile

func (UserProfiles) BulkDelete

func (up UserProfiles) BulkDelete(tx ITransaction) error

func (UserProfiles) BulkInsert

func (up UserProfiles) BulkInsert(tx ITransaction) (int64, error)

Jump to

Keyboard shortcuts

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