db

package
v0.0.0-...-297d307 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

func (*Builder) Delete

func (b *Builder) Delete(table string, conds ...string) string

func (*Builder) GetColumnNames

func (b *Builder) GetColumnNames(v interface{}) []string

func (*Builder) InsertStruct

func (b *Builder) InsertStruct(table string, v interface{}) string

func (*Builder) Select

func (b *Builder) Select(table string, columns []string, conditions ...string) string

func (*Builder) String

func (b *Builder) String() string

func (*Builder) Update

func (b *Builder) Update(table string, sets []string, conditions ...string) string

func (*Builder) WriteRune

func (b *Builder) WriteRune(r rune)

func (*Builder) WriteString

func (b *Builder) WriteString(s string)

type DB

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

DB for db

func New

func New(o *Options) (*DB, error)

func (*DB) CreateNamespace

func (d *DB) CreateNamespace(ctx context.Context, x *sqlx.Tx, ns *Namespace) error

func (*DB) CreateObject

func (d *DB) CreateObject(ctx context.Context, x *sqlx.Tx, obj *types.Object)

func (*DB) DeleteAllObjectLabels

func (d *DB) DeleteAllObjectLabels(ctx context.Context, x *sqlx.Tx, nsID types.NSID, objID types.ObjID) error

Delete all labels of objects

func (*DB) DeleteNamespace

func (d *DB) DeleteNamespace(ctx context.Context, x *sqlx.Tx, ns *Namespace) error

func (*DB) DeleteObjectLabels

func (d *DB) DeleteObjectLabels(ctx context.Context, x *sqlx.Tx, nsID types.NSID, objID types.ObjID, keys []string) error

func (*DB) FindObjectsMatchingSelector

func (d *DB) FindObjectsMatchingSelector(ctx context.Context, nsID types.NSID, tm *types.TypeMeta, sel *selector.Selector) ([]types.ObjID, error)

func (*DB) GetNamespaceByID

func (d *DB) GetNamespaceByID(ctx context.Context, id types.NSID) (*Namespace, error)

func (*DB) GetNamespaceByKey

func (d *DB) GetNamespaceByKey(ctx context.Context, key string) (*Namespace, error)

func (*DB) ListNamespace

func (d *DB) ListNamespace(ctx context.Context, parent *Namespace, page *types.Page) ([]*Namespace, error)

func (*DB) ListObjectLabels

func (d *DB) ListObjectLabels(ctx context.Context, nsID types.NSID, objID types.ObjID) ([]types.Label, error)

func (*DB) Migrate

func (d *DB) Migrate() error

func (*DB) UpdateNamespace

func (d *DB) UpdateNamespace(ctx context.Context, ns *Namespace) error

func (*DB) UpdateObjectLabels

func (d *DB) UpdateObjectLabels(ctx context.Context, x *sqlx.Tx, meta *types.ObjectMeta) error

func (*DB) X

func (d *DB) X(ctx context.Context, fn func(tx *sqlx.Tx) error, opts ...*sql.TxOptions) error

X start transaction

type Label

type Label struct {
	NSID    types.NSID  `db:"ns_id"`
	ObjID   types.ObjID `db:"obj_id"`
	TypeSig uint32      `db:"type_sig"`
	types.Label
}

type Namespace

type Namespace struct {
	ID        types.NSID
	Name      string     `validate:"required,max=64"`
	Key       string     `validate:"required,max=64"`
	ParentID  types.NSID `db:"parent_id"`
	CreatedAt types.Time `db:"created_at"`
	UpdatedAt types.Time `db:"updated_at"`
}

type Options

type Options struct {
	Driver string
	URI    string

	ConnMaxLifetime time.Duration
	MaxOpenConns    int
	MaxIdleConns    int
}

Options for db

type StmtFunc

type StmtFunc func() (*sqlx.Stmt, error)

type UUID

type UUID uuid.UUID

func NewUUID

func NewUUID() UUID

func (*UUID) Scan

func (u *UUID) Scan(src interface{}) error

Scan implements the sql.Scanner interface, and turns the bitfield incoming from MySQL into a BitBool

func (UUID) Value

func (u UUID) Value() (driver.Value, error)

Value implements the driver.Valuer interface, and turns the BitBool into a bitfield (BIT(1)) for MySQL storage.

Jump to

Keyboard shortcuts

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