database

package module
v0.0.0-...-16b35d8 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 8 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SETTINGS_REPO = "thunderbyte_settings"
	AUTH_USER     = "auth_users"
	AUTH_PASSWORD = "auth_passwords"
)

Variables

This section is empty.

Functions

func ForRoot

func ForRoot(c *DBConfig, l *logf.Logger)

ForRoot Sets up a connection to the database, sets up the schema and initializes a repository struct to be used throughout the application. Panics if it fails to achieve any of the condition

Types

type AuthProfile

type AuthProfile struct {
	UserId   int64  `db:"id"`
	Username string `db:"username"`
}

type DBConfig

type DBConfig struct {
	SQLFilePaths
	// Queries must be a pointer kind ( a pointer to a struct )
	Queries
	Type     DBType
	Host     string
	Port     int
	User     string
	Password string
	Database string
	SSLMode  string
	Params   string
	// contains filtered or unexported fields
}

func (*DBConfig) GetDB

func (dbc *DBConfig) GetDB() *sqlx.DB

func (*DBConfig) GetDefaultQueries

func (dbc *DBConfig) GetDefaultQueries() ThunderbyteQueries

GetDefaultQueries returns the queries for the inbuilt repos within thunderbyte

type DBType

type DBType string
const (
	Postgres DBType = "postgres"
)

type Queries

type Queries interface{}

Queries contains all prepared SQL queries.

type SQLFilePaths

type SQLFilePaths struct {
	// QueryFilePath .sql file containing all the queries to be executed. Useful
	// for separating SQL from code logic
	QueryFilePath *string
	// SchemaFilePath .sql file containing the SQL commands. This can have SQL commands
	// to create / alter tables. Use CREATE TABLE IF NOT EXISTS for all create
	// table queries. For any subsequent modifications,
	// add alter queries inside the schema file and those changes
	// will be synced during the server boot.
	SchemaFilePath *string
}

type ThunderByteSetting

type ThunderByteSetting struct {
	ID    int    `db:"id"`
	Key   string `db:"key"`
	Value string `db:"value"`
}

type ThunderByteSettings

type ThunderByteSettings []ThunderByteSetting

type ThunderbyteQueries

type ThunderbyteQueries struct {
	GetAllSettings             *sqlx.Stmt `query:"get-all-settings"`
	GetSettingByKey            *sqlx.Stmt `query:"get-setting-by-key"`
	VerifyCredentials          *sqlx.Stmt `query:"verify-creds"`
	FetchAuthProfileByUsername *sqlx.Stmt `query:"fetch-auth-profile-by-username"`
	FetchAuthProfileById       *sqlx.Stmt `query:"fetch-auth-profile-by-id"`
	CreateAuthProfile          *sqlx.Stmt `query:"create-auth-profile"`
	CreatePassword             *sqlx.Stmt `query:"create-password"`
}

type VerifiedUser

type VerifiedUser struct {
	UserId   int64  `db:"userid"`
	Username string `db:"username"`
}

Jump to

Keyboard shortcuts

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