store

package
v0.0.0-...-0ddd045 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package store provides an interface for all database operations

Index

Constants

This section is empty.

Variables

View Source
var DefaultSettings = &Settings{
	IsInstalled:      false,
	SuperadminExists: false,
}

DefaultSettings provide the default values for settings

View Source
var (
	// ErrInvalidDatabaseType indicates the provided database type is not supported
	ErrInvalidDatabaseType = errors.New("Invalid database type")
)

Functions

func DSN

func DSN(options config.StoreOptions) string

DSN returns a data source name for a database connection, refer https://github.com/go-sql-driver/mysql#dsn-data-source-name

Types

type Settings

type Settings struct {
	ID               uint
	IsInstalled      bool
	SuperadminExists bool
}

Settings holds settings data

type Store

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

Store wraps a sqlx database connection

func New

func New(t string, options config.StoreOptions) (*Store, error)

New returns a new store instance

func (*Store) CreateInvite

func (s *Store) CreateInvite(invite *models.Invite) error

CreateInvite creates a new invite

func (*Store) CreateRoom

func (s *Store) CreateRoom(room *models.Room) error

CreateRoom inserts a new room entry into the database

func (*Store) CreateServer

func (s *Store) CreateServer(server *models.Server) error

CreateServer inserts a new server entry into the database

func (*Store) CreateUser

func (s *Store) CreateUser(user models.PublicUser) error

func (*Store) DeleteRoom

func (s *Store) DeleteRoom(roomHash string) error

DeleteRoom deletes ONE room entry with provided 'roomHash' from the database

func (*Store) DeleteServer

func (s *Store) DeleteServer(serverHash string) error

DeleteServer deletes ONE server entry with provided 'serverHash' from the database

func (*Store) GetRoom

func (s *Store) GetRoom(roomHash string) (*models.Room, error)

GetRoom selects ONE room entry with provided 'roomHash' from the database

func (*Store) GetRooms

func (s *Store) GetRooms() ([]models.Room, error)

GetRooms selects multiple room entries from the database

func (*Store) GetServer

func (s *Store) GetServer(serverHash string) (*models.Server, error)

GetServer selects ONE server entry with provided 'serverHash' from the database

func (*Store) GetServers

func (s *Store) GetServers() ([]models.Server, error)

GetServers selects multiple server entries from the database

func (*Store) GetSettings

func (s *Store) GetSettings() (*Settings, error)

GetSettings returns the settings or creates a new default entry in the database

func (*Store) GetUser

func (s *Store) GetUser(username string) (models.User, error)

func (*Store) GetUserPublicKey

func (s *Store) GetUserPublicKey(username string) (string, error)

func (*Store) GetUserServers

func (s *Store) GetUserServers(username string) error

func (*Store) Migrate

func (s *Store) Migrate() error

Migrate migrates the neccesary database tables

func (*Store) UpdateRoom

func (s *Store) UpdateRoom(roomHash string, new *models.Room) error

UpdateRoom updates ONE room entry with provided 'roomHash' in the database

func (*Store) UpdateServer

func (s *Store) UpdateServer(serverHash string, new *models.Server) error

UpdateServer updates ONE server entry with provided 'serverHash' in the database

func (*Store) UpdateTwoFAVerify

func (s *Store) UpdateTwoFAVerify(username, verify string) error

func (*Store) UpdateUser

func (s *Store) UpdateUser(username string, user *models.User) error

Directories

Path Synopsis
Package schemas provides database schemas
Package schemas provides database schemas

Jump to

Keyboard shortcuts

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