data

package
v0.0.0-...-d67a7ed Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	IsConnected() (bool, error)
	GetTeams(teamid *int) (Teams, error)
	GetTeamsByActivation(activation string) (Teams, error)
	CreateTeam(*Team) (Team, error)
	DeleteTeam(teamID int) error
	GetUser(username string) (Users, error)
	CreateToken(int) (Token, error)
	GetToken(int, int) (Token, error)
	DeleteToken(int, int) error
}

func New

func New(connection string) (Connection, error)

New creates a new connection to the database

type MockConnection

type MockConnection struct {
	mock.Mock
}

func (*MockConnection) CreateTeam

func (c *MockConnection) CreateTeam(team *Team) (Team, error)

CreateTeam -

func (*MockConnection) CreateToken

func (c *MockConnection) CreateToken(userID int) (Token, error)

CreateToken -

func (*MockConnection) DeleteTeam

func (c *MockConnection) DeleteTeam(teamId int) error

DeleteTeam -

func (*MockConnection) DeleteToken

func (c *MockConnection) DeleteToken(tokenID int, userID int) error

DeleteToken -

func (*MockConnection) GetTeams

func (c *MockConnection) GetTeams(*int) (Teams, error)

GetTeams -

func (*MockConnection) GetTeamsByActivation

func (c *MockConnection) GetTeamsByActivation(string) (Teams, error)

GetTeamsByActivation -

func (*MockConnection) GetToken

func (c *MockConnection) GetToken(tokenID int, userID int) (Token, error)

GetToken -

func (*MockConnection) GetUser

func (c *MockConnection) GetUser(string) (Users, error)

GetUser -

func (*MockConnection) IsConnected

func (c *MockConnection) IsConnected() (bool, error)

IsConnected -

type PostgresSQL

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

func (*PostgresSQL) CreateTeam

func (c *PostgresSQL) CreateTeam(team *Team) (Team, error)

CreateTeam creates a new team

func (*PostgresSQL) CreateToken

func (c *PostgresSQL) CreateToken(userID int) (Token, error)

CreateToken creates a new token

func (*PostgresSQL) DeleteTeam

func (c *PostgresSQL) DeleteTeam(teamID int) error

DeleteTeam deletes an existing team in the database

func (*PostgresSQL) DeleteToken

func (c *PostgresSQL) DeleteToken(tokenID int, userID int) error

DeleteToken deletes an existing token in the database

func (*PostgresSQL) GetTeams

func (c *PostgresSQL) GetTeams(teamid *int) (Teams, error)

GetTeams returns all teams from the database

func (*PostgresSQL) GetTeamsByActivation

func (c *PostgresSQL) GetTeamsByActivation(activation string) (Teams, error)

GetTeamsByActivation returns all teams from the database by activation

func (*PostgresSQL) GetToken

func (c *PostgresSQL) GetToken(tokenID int, userID int) (Token, error)

GetToken checks whether token exists

func (*PostgresSQL) GetUser

func (c *PostgresSQL) GetUser(username string) (Users, error)

func (*PostgresSQL) IsConnected

func (c *PostgresSQL) IsConnected() (bool, error)

IsConnected checks the connection to the database and returns an error if not connected

type Team

type Team struct {
	ID         int            `db:"id" json:"id"`
	Name       string         `db:"name" json:"name"`
	Activation string         `db:"activation" json:"activation"`
	Time       float64        `db:"time" json:"time"`
	CreatedAt  string         `db:"created_at" json:"-"`
	DeletedAt  sql.NullString `db:"deleted_at" json:"-"`
}

func (*Team) FromJson

func (t *Team) FromJson(data io.Reader) error

FromJSON serializes data from json

func (*Team) ToJSON

func (t *Team) ToJSON() ([]byte, error)

ToJSON converts the collection to json

type Teams

type Teams []Team

Teams is a list of Team

func (*Teams) FromJSON

func (t *Teams) FromJSON(data io.Reader) error

FromJSON serializes data from json

func (*Teams) ToJSON

func (t *Teams) ToJSON() ([]byte, error)

ToJSON converts the collection to json

type Token

type Token struct {
	ID        int    `db:"id" json:"id"`
	UserID    int    `db:"user_id" json:"user_id"`
	CreatedAt string `db:"created_at" json:"-"`
	DeletedAt string `db:"deleted_at" json:"-"`
}

Token defines a JWT in the database

func (*Token) FromJSON

func (t *Token) FromJSON(data io.Reader) error

FromJSON serializes data from json

func (*Token) ToJSON

func (t *Token) ToJSON() ([]byte, error)

ToJSON converts the collection to json

type User

type User struct {
	ID       int    `db:"id" json:"id"`
	Username string `db:"username" json:"username"`
	Password string `db:"password" json:"-"`
}

type Users

type Users []User

Users is a list of users for administration

Jump to

Keyboard shortcuts

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