db

package
v0.0.0-...-1ee42d9 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect() (*sql.DB, error)

Connect opens the connection with Database

Types

type Products

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

func NewProductInstance

func NewProductInstance(db *sql.DB) *Products

NewInstance creates a instance for connecting to Products table in database

func (Products) Create

func (p Products) Create(product *models.Product) error

Create creates an item in Database

func (Products) DeleteProduct

func (p Products) DeleteProduct(productID string) error

DeleteProduct deletes a product by its ID

func (Products) GetByID

func (p Products) GetByID(productID string) (models.Product, error)

GetByID gets an product in database by its ID

func (Products) ListAll

func (p Products) ListAll() ([]models.Product, error)

ListAll lists all products in database

func (Products) UpdateProduct

func (p Products) UpdateProduct(productID string, product *models.Product) (string, error)

UpdateProduct updates a single product by its ID

Jump to

Keyboard shortcuts

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