db

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	DbHandler *gorm.DB
}

Database GORM wrapper

func NewDatabase

func NewDatabase(db *gorm.DB) *Database

NewDatabase is Database constructor

func (*Database) AddForeignKey

func (d *Database) AddForeignKey(tableStruct interface{}, field, dest, onDelete, onUpdate string) error

AddForeignKey adds constraints to table

func (*Database) AddUniqueIndex

func (d *Database) AddUniqueIndex(tableStruct interface{}, indexName string, fields ...string) error

AddUniqueIndex adds unique index to table

func (*Database) CreateDB

func (d *Database) CreateDB(dbName string) error

CreateDB creates database

func (*Database) CreateEnum added in v0.2.0

func (d *Database) CreateEnum(enumName string, values []string) error

CreateEnum creates enum in database

func (*Database) CreateTables

func (d *Database) CreateTables(tablesStruct ...interface{}) error

CreateTables creates DB tables from table structs

func (*Database) DropDB

func (d *Database) DropDB(dbName string) error

DropDB drops database

func (*Database) DropEnum added in v0.2.0

func (d *Database) DropEnum(enumName string) error

DropEnum deletes enum in database

func (*Database) MigrateDB

func (d *Database) MigrateDB(tableStruct ...interface{}) error

MigrateDB migrates DB from table structs

func (*Database) UpdateEnum added in v0.2.0

func (d *Database) UpdateEnum(enumName, value string) error

UpdateEnum updates enum in database

func (*Database) WithEndingBefore added in v0.5.0

func (d *Database) WithEndingBefore(tableName string, limit uint, before string) func(db *gorm.DB) *gorm.DB

WithStartingAfter is a query scope for cursors

func (*Database) WithExternalIDs added in v0.5.0

func (d *Database) WithExternalIDs(tableName string, externalIDs []sql.NullString) func(db *gorm.DB) *gorm.DB

WithStartingAfter is a query scope for external IDs

func (*Database) WithIDs added in v0.5.0

func (d *Database) WithIDs(tableName string, ids []string) func(db *gorm.DB) *gorm.DB

WithIDs is a query scope to include the given IDs (string IDs)

func (*Database) WithIds

func (d *Database) WithIds(ids []uint, tableName string) func(db *gorm.DB) *gorm.DB

WithIds is a query scope function to include given IDs (integer IDs)

func (*Database) WithLimitAndOffset

func (d *Database) WithLimitAndOffset(limit uint, offset uint) func(db *gorm.DB) *gorm.DB

WithLimitAndOffset is a query scope function for pagination

func (*Database) WithNotIds

func (d *Database) WithNotIds(ids []uint, tableName string) func(db *gorm.DB) *gorm.DB

WithNotIds is a query scope function to exclude given ids

func (*Database) WithOrgID added in v0.5.0

func (d *Database) WithOrgID(tableName string, id uint) func(db *gorm.DB) *gorm.DB

WithStartingAfter is a query scope for organization ID

func (*Database) WithStartingAfter added in v0.5.0

func (d *Database) WithStartingAfter(tableName string, limit uint, after string) func(db *gorm.DB) *gorm.DB

WithStartingAfter is a query scope for cursors

Jump to

Keyboard shortcuts

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