Version: v0.0.0-...-3338f27 Latest Latest

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 19 Imported by: 804




View Source
const (
	// NonExistUserID : if a user does not exist, the ID of the user will be 0.
	NonExistUserID = 0


View Source
var ErrDupRows = errors.New("sql: duplicate row in DB")

ErrDupRows is returned by DAO when inserting failed with error "duplicate key value violates unique constraint"


func ArrayEqual

func ArrayEqual(arrayA, arrayB []int) bool

ArrayEqual ...

func ClearHTTPAuthProxyUsers

func ClearHTTPAuthProxyUsers() error

ClearHTTPAuthProxyUsers remove the records from harbor_users to delete all user imported via HTTP Auth Proxy

func ClearTable

func ClearTable(table string) error

ClearTable is the shortcut for test cases, it should be called only in test cases.

func ExecuteBatchSQL

func ExecuteBatchSQL(sqls []string)

ExecuteBatchSQL ...

func GetOrmer

func GetOrmer() orm.Ormer

GetOrmer :set ormer singleton

func InitDatabase

func InitDatabase(database *models.Database) error

InitDatabase registers the database

func JoinNumberConditions

func JoinNumberConditions(ids []int) string

JoinNumberConditions - To join number condition into string,used in sql query

func NewMigrator

func NewMigrator(database *models.PostGreSQL) (*migrate.Migrate, error)

NewMigrator creates a migrator base on the information

func PrepareTestData

func PrepareTestData(clearSqls []string, initSqls []string)

PrepareTestData -- Clean and Create data

func PrepareTestForPostgresSQL

func PrepareTestForPostgresSQL()

PrepareTestForPostgresSQL is for test only.

func PrepareTestForSQLite

func PrepareTestForSQLite()

PrepareTestForSQLite is for test only.

func UpgradeSchema

func UpgradeSchema(database *models.Database) error

UpgradeSchema will call the internal migrator to upgrade schema based on the setting of database.


type Database

type Database interface {
	// Name returns the name of database
	Name() string
	// String returns the details of database
	String() string
	// Register registers the database which will be used
	Register(alias ...string) error
	// UpgradeSchema upgrades the DB schema to the latest version
	UpgradeSchema() error

Database is an interface of different databases

func NewPGSQL

func NewPGSQL(host string, port string, usr string, pwd string, database string, sslmode string, maxIdleConns int, maxOpenConns int, connMaxLifetime time.Duration, connMaxIdleTime time.Duration) Database

NewPGSQL returns an instance of postgres

func NewSQLite

func NewSQLite(file string) Database

NewSQLite returns an instance of sqlite

Jump to

Keyboard shortcuts

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