database

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDocumentNotFound = errors.New("document not found")
	ErrUserNotFound     = errors.New("user not found")
)

Functions

This section is empty.

Types

type Agreement

type Agreement struct {
	UserUUID     string    `json:"user_uuid"`
	DocumentName string    `json:"document_name"`
	Date         time.Time `json:"date"`
}

type DB

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

func NewDB

func NewDB(connstr string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) GetAgreementsForUserUUID

func (db *DB) GetAgreementsForUserUUID(uuid string) ([]Agreement, error)

func (*DB) GetDocument

func (db *DB) GetDocument(name string) (Document, error)

func (*DB) GetDocumentsForUserUUID

func (db *DB) GetDocumentsForUserUUID(uuid string) ([]UserDocument, error)

func (*DB) GetUser

func (db *DB) GetUser(uuid string) (User, error)

func (*DB) GetUserByEmail added in v0.6.0

func (db *DB) GetUserByEmail(email string) ([]*User, error)

func (*DB) GetUserByUsername added in v0.9.0

func (db *DB) GetUserByUsername(username string) (User, error)

func (*DB) GetUsersByUUID added in v0.6.0

func (db *DB) GetUsersByUUID(uuids []string) ([]*User, error)

func (*DB) Init

func (db *DB) Init() error

func (*DB) PatchUser added in v0.6.0

func (db *DB) PatchUser(user User) error

func (*DB) Ping

func (db *DB) Ping() error

func (*DB) PostUser added in v0.6.0

func (db *DB) PostUser(user User) error

func (*DB) PutAgreement

func (db *DB) PutAgreement(agreement Agreement) error

func (*DB) PutDocument

func (db *DB) PutDocument(doc Document) error

type Document

type Document struct {
	Name      string    `json:"name"`
	Content   string    `json:"content"`
	ValidFrom time.Time `json:"valid_from"`
}

type TempDB

type TempDB struct {
	MasterConnectionString string
	TempConnectionString   string
}

func NewTempDB

func NewTempDB() (*TempDB, error)

func (*TempDB) Close

func (db *TempDB) Close() error

Close drops the database

type User

type User struct {
	UUID     string  `json:"user_uuid" validate:"uuid"`
	Email    *string `json:"user_email" validate:"omitempty,email"`
	Username *string `json:"username" validate:"required,min=1"`
}

type UserDocument

type UserDocument struct {
	Name          string     `json:"name"`
	Content       string     `json:"content"`
	ValidFrom     time.Time  `json:"valid_from"`
	AgreementDate *time.Time `json:"agreement_date"`
}

Jump to

Keyboard shortcuts

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