database

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alias

type Alias struct {
	gorm.Model

	Host   string
	Domain string
	Value  string
	UserID uint // FK
}

Alias is the mapping of a DyDNS alias

type Connection

type Connection interface {
	CreateUser(email, hashedPassword string) (User, error)
	FindUser(email string) (User, error)
	FindUserAliases(userID uint) ([]Alias, error)
	FindAlias(host, domain string) (Alias, error)
	CreateAlias(alias Alias, userID uint) (Alias, error)
	DeleteAlias(host, domain string, userID uint) error
	UpdateAlias(alias Alias) (Alias, error)
}

Connection represent a connection to the database to perform CRUD

func OpenConnection

func OpenConnection(conf config.DatabaseConfig, logger *zerolog.Logger) (Connection, error)

OpenConnection tries to open a new database connection using given config

type User

type User struct {
	gorm.Model

	Email    string `gorm:"unique"`
	Password string

	Aliases []Alias
}

User is the mapping of an user

Jump to

Keyboard shortcuts

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