db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package db contains the database implementation of the quoting api.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	*gorm.DB
	// contains filtered or unexported fields
}

Database is the database object.

func NewDatabase

func NewDatabase(ctx context.Context, handler metrics.Handler, skipMigrations bool, dbType, dsn string) (db *Database, err error)

NewDatabase creates a new instance of the database. TODO: consider returning an interface instead of a concrete type. TODO: make dbType a string

func (*Database) DeleteQuote

func (db *Database) DeleteQuote(c context.Context, id uint) error

DeleteQuote deletes a quote from the database.

func (*Database) GetQuote

func (db *Database) GetQuote(c context.Context, id uint) (q models.Quote, err error)

GetQuote gets a quote from the database.

func (*Database) GetQuotes

func (db *Database) GetQuotes(c context.Context, req *models.Request) (qs []models.Quote, err error)

GetQuotes gets quotes from the database.

func (*Database) InsertQuote

func (db *Database) InsertQuote(c context.Context, q *models.Quote) (id uint, err error)

InsertQuote inserts a quote into the database.

func (*Database) UpdateQuote

func (db *Database) UpdateQuote(c context.Context, q *models.Quote) error

UpdateQuote updates a quote in the database.

Jump to

Keyboard shortcuts

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