database

package
v0.0.0-...-fae5159 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRecord

func CreateRecord(parameters CreationParameters) error

Create database record

func Disconnect

func Disconnect() error

Disconnect from the database

func ForceDeleteRecord

func ForceDeleteRecord(model Model) error

Force Delete model from the database

func GetCount

func GetCount(model interface{}) (uint64, error)

Count total number of records on the table

func GetRecord

func GetRecord(query *DatabaseQuery) error

Get record from the database

func Instance

func Instance() *gorm.DB

Get database connection instance

func RecordExists

func RecordExists(model Model) (bool, error)

Check if record already exists in the database

func SoftDeleteRecord

func SoftDeleteRecord(model Model) error

Soft Delete model from the database

func UpdateRecord

func UpdateRecord(model Model, fieldValueMap map[string]interface{}) error

Update database record

Types

type CreationParameters

type CreationParameters struct {
	Model        Model
	CreateWithID bool
}

type DatabaseClient

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

func Initialize

func Initialize(app *service.Application) *DatabaseClient

Initialize database client

func (*DatabaseClient) Connect

func (client *DatabaseClient) Connect() error

Connect to the database

func (*DatabaseClient) SynchronizeWithTMDB

func (client *DatabaseClient) SynchronizeWithTMDB() error

Synchronize database with TMDB sources

type DatabaseOrder

type DatabaseOrder struct {
	Column string
	Order  string
}

type DatabaseQuery

type DatabaseQuery struct {
	Output     interface{}
	Query      interface{}
	Parameters interface{}
	All        bool
	Multiple   bool
	Count      bool
	Counted    int64
	Order      DatabaseOrder
	Limit      int64
	Offset     int64
	Columns    []string
}

type Model

type Model interface {
	PrimaryKey() uint64
	BeforeCreate(*gorm.DB) error
	BeforeUpdate(*gorm.DB) error
	BeforeDelete(*gorm.DB) error
	TableName() string
	UpdatedFields(updateID bool, updatedFields ...string) map[string]interface{}
}

Jump to

Keyboard shortcuts

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