dao

package
v0.0.0-...-66c98c8 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAO

type DAO interface {
	// Count returns the total count of quotas according to the query.
	Count(ctx context.Context, query *q.Query) (int64, error)

	// Create create quota for reference object
	Create(ctx context.Context, reference, referenceID string, hardLimits, used types.ResourceList) (int64, error)

	// Delete delete quota by id
	Delete(ctx context.Context, id int64) error

	// Get returns quota by id
	Get(ctx context.Context, id int64) (*models.Quota, error)

	// GetByRef returns quota by reference object
	GetByRef(ctx context.Context, reference, referenceID string) (*models.Quota, error)

	// Update update quota
	Update(ctx context.Context, quota *models.Quota) error

	// List list quotas
	List(ctx context.Context, query *q.Query) ([]*models.Quota, error)
}

DAO the dao for Quota and QuotaUsage

func New

func New() DAO

New returns an instance of the default DAO

type Quota

type Quota struct {
	ID           int64     `orm:"pk;auto;column(id)" json:"id"`
	Reference    string    `orm:"column(reference)" json:"reference"` // The reference type for quota, eg: project, user
	ReferenceID  string    `orm:"column(reference_id)" json:"reference_id"`
	Hard         string    `orm:"column(hard);type(jsonb)" json:"-"`
	CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
	UpdateTime   time.Time `orm:"column(update_time);auto_now" json:"update_time"`
	Version      int64     `orm:"column(version)" json:"-"`
}

Quota model for quota

func (*Quota) TableName

func (q *Quota) TableName() string

TableName returns table name for orm

type QuotaUsage

type QuotaUsage struct {
	ID           int64     `orm:"pk;auto;column(id)" json:"id"`
	Reference    string    `orm:"column(reference)" json:"reference"` // The reference type for quota usage, eg: project, user
	ReferenceID  string    `orm:"column(reference_id)" json:"reference_id"`
	Used         string    `orm:"column(used);type(jsonb)" json:"-"`
	CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
	UpdateTime   time.Time `orm:"column(update_time);auto_now" json:"update_time"`
	Version      int64     `orm:"column(version)" json:"-"`
}

QuotaUsage model for quota usage

func (*QuotaUsage) TableName

func (qu *QuotaUsage) TableName() string

TableName returns table name for orm

Jump to

Keyboard shortcuts

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