postgres

package
v0.0.0-...-e6dd299 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresDriver

type PostgresDriver struct {
	// External data
	DbHost string
	DbPort int
	DbUser string
	DbPass string
	DbName string

	// Internal data
	Db *gorm.DB
}

func NewPostgresDriver

func NewPostgresDriver(host string, port int, user string, pass string, dbName string, logger zerolog.Logger) *PostgresDriver

NewPostgresDriver creates a new instance of PostgresDriver

func (*PostgresDriver) Close

func (p *PostgresDriver) Close() error

Close closes the connection to the database

func (*PostgresDriver) Connect

func (p *PostgresDriver) Connect() error

Connect establishes a connection to the database

func (*PostgresDriver) DeleteUserData

func (p *PostgresDriver) DeleteUserData(accountID string) error

DeleteUserData deletes a user data record from the database

func (*PostgresDriver) GetUserData

func (p *PostgresDriver) GetUserData(accountID string) (string, time.Time, error)

GetUserData retrieves a user data record from the database

func (*PostgresDriver) InsertUserData

func (p *PostgresDriver) InsertUserData(accountID string, data string) error

InsertUserData inserts a new user data record into the database

func (*PostgresDriver) Migrate

func (p *PostgresDriver) Migrate() error

Migrate the schema to database

type UserData

type UserData struct {
	ID        uint      `gorm:"primaryKey"`
	AccountID string    `gorm:"column:account_id;"`
	Timestamp time.Time `gorm:"column:timestamp;"`
	Data      string    `gorm:"column:data;"`
}

UserData model

Jump to

Keyboard shortcuts

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