db

package
v0.0.0-...-9d72ccb Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupDB

func SetupDB(logLevel types.LogLevelParams) error

func ShutdownDB

func ShutdownDB() error

Types

type DB

type DB struct {
	DB       *gorm.DB
	LogLevel types.LogLevelParams
}
var Database *DB

func InitTesterDB

func InitTesterDB() (*DB, error)

func (*DB) CheckNoteExists

func (db *DB) CheckNoteExists(conditions Note) (bool, error)

func (*DB) CheckUserExists

func (db *DB) CheckUserExists(conditions User) (bool, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) CreateNote

func (db *DB) CreateNote(note *Note) error

func (*DB) CreateUser

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

func (*DB) DeleteNote

func (db *DB) DeleteNote(conditions Note) error

func (*DB) DeleteUser

func (db *DB) DeleteUser(conditions User) error

func (*DB) GetNotes

func (db *DB) GetNotes(conditions Note) ([]Note, error)

func (*DB) GetUsers

func (db *DB) GetUsers(conditions User) ([]User, error)

func (*DB) Init

func (db *DB) Init() error

type Note

type Note struct {
	ID     int
	Name   string `gorm:"unique;not null"`
	Body   string `gorm:"not null"`
	UserID int    `gorm:"not null"`
	User   User   `gorm:"constraint:OnDelete:CASCADE;"`
}

type User

type User struct {
	ID       int
	Username string `gorm:"unique;not null"`
	Password string `gorm:"not null"`
}

Jump to

Keyboard shortcuts

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