repository

package
v0.0.0-...-89ae45c Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host       string
	Port       string
	User       string
	Password   string
	DbName     string
	SSLMode    string
	Driver     string
	StringConn string
}

Config is a struct to hold the database configuration

type ListsDB

type ListsDB struct {
	ID     sql.NullInt64  `db:"id"`
	List1  sql.NullString `db:"list_1"`
	List2  sql.NullString `db:"list_2"`
	Merged sql.NullString `db:"merged"`
}

ListsDB is a struct to use in the database to bear the models.ListNode

type Repository

type Repository struct {
	Db     *sqlx.DB
	Config Config
}

Repository is a struct to hold the database connection

func NewRepository

func NewRepository(config Config) *Repository

NewRepository returns a new Repository

func (*Repository) CreateListNodeTable

func (r *Repository) CreateListNodeTable() error

CreateListNodeTable is a function to create the list_node table in the database

func (*Repository) GetConnection

func (r *Repository) GetConnection()

GetConnection returns a connection to the database

func (*Repository) InsertLists

func (r *Repository) InsertLists(lists []*models.ListNode) (int64, error)

InsertLists is a function to insert a list into the database

func (*Repository) SelectLists

func (r *Repository) SelectLists(id int64) ([]*models.ListNode, error)

SelectLists is a function to select all lists from the database based on the id

func (*Repository) UpdateMergedList

func (r *Repository) UpdateMergedList(mergedList models.ListNode, id int64) error

UpdateMergedList is a function to update the merged list in the database

Jump to

Keyboard shortcuts

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