dbmgr

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFiltered = errors.New("actions requires query to be filtered, but no filters were applied")
)

Functions

This section is empty.

Types

type AuthToken

type AuthToken struct {
	gorm.Model
	Token     string `gorm:"unique"`
	TokenHash string
	Label     string
	User      UserID
	Expiry    time.Time
}

type AuthTokensQuery

type AuthTokensQuery struct{ DB *gorm.DB }

func NewAuthTokensQuery

func NewAuthTokensQuery(db *gorm.DB) *AuthTokensQuery

func (*AuthTokensQuery) Create

func (q *AuthTokensQuery) Create(authToken AuthToken) error

type ClaimedInvite

type ClaimedInvite struct {
	Code      string
	Username  string
	ClaimedBy string
}

type Collection

type Collection struct {
	ID        CollectionID `gorm:"primarykey"`
	CreatedAt time.Time

	UUID string `gorm:"index"`

	Name        string `gorm:"unique"`
	Description string
	UserID      UserID
}

type CollectionID

type CollectionID uint

type CollectionRef

type CollectionRef struct {
	ID         CollectionRefID `gorm:"primarykey"`
	CreatedAt  time.Time
	Collection CollectionID
	Content    ContentID
}

type CollectionRefID

type CollectionRefID uint

type CollectionRefsQuery

type CollectionRefsQuery struct{ DB *gorm.DB }

func NewCollectionRefsQuery

func NewCollectionRefsQuery(db *gorm.DB) *CollectionRefsQuery

func (*CollectionRefsQuery) Create

func (q *CollectionRefsQuery) Create(collectionRef CollectionRef) error

type CollectionsQuery

type CollectionsQuery struct{ DB *gorm.DB }

func NewCollectionsQuery

func NewCollectionsQuery(db *gorm.DB) *CollectionsQuery

func (*CollectionsQuery) Get

func (q *CollectionsQuery) Get() (Collection, error)

func (*CollectionsQuery) WithUUID

func (q *CollectionsQuery) WithUUID(uuid string) *CollectionsQuery

func (*CollectionsQuery) WithUserID

func (q *CollectionsQuery) WithUserID(userID uint) *CollectionsQuery

type Content

type Content struct {
	ID        uint `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`

	Cid         util.DbCID
	Filename    string
	UserID      UserID
	Description string
	Size        int64
	Type        util.ContentType
	Active      bool
	Offloaded   bool
	Replication int

	AggregatedIn ContentID
	Aggregate    bool

	Pinning bool
	PinMeta string

	Failed bool

	Location string
}

type ContentID

type ContentID uint

type ContentsQuery

type ContentsQuery struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

func NewContentsQuery

func NewContentsQuery(db *gorm.DB) *ContentsQuery

func (*ContentsQuery) Count

func (q *ContentsQuery) Count() (int64, error)

func (*ContentsQuery) CreateAll

func (q *ContentsQuery) CreateAll(contents []Content) error

func (*ContentsQuery) Delete

func (q *ContentsQuery) Delete() error

func (*ContentsQuery) Get

func (q *ContentsQuery) Get() (Content, error)

func (*ContentsQuery) GetAll

func (q *ContentsQuery) GetAll() ([]Content, error)

func (*ContentsQuery) Limit

func (q *ContentsQuery) Limit(limit int) *ContentsQuery

func (*ContentsQuery) Offset

func (q *ContentsQuery) Offset(offset int) *ContentsQuery

func (*ContentsQuery) OrderByCreationDate

func (q *ContentsQuery) OrderByCreationDate(order DBSortOrder) *ContentsQuery

TODO: order functions can probably be simplified

func (*ContentsQuery) OrderByID

func (q *ContentsQuery) OrderByID(order DBSortOrder) *ContentsQuery

func (*ContentsQuery) WithActive

func (q *ContentsQuery) WithActive(active bool) *ContentsQuery

func (*ContentsQuery) WithAggregate

func (q *ContentsQuery) WithAggregate(aggregate bool) *ContentsQuery

func (*ContentsQuery) WithAggregatedIn

func (q *ContentsQuery) WithAggregatedIn(contentID uint) *ContentsQuery

func (*ContentsQuery) WithCid

func (q *ContentsQuery) WithCid(cid gocid.Cid) *ContentsQuery

func (*ContentsQuery) WithCids

func (q *ContentsQuery) WithCids(cids []gocid.Cid) *ContentsQuery

func (*ContentsQuery) WithID

func (q *ContentsQuery) WithID(id uint) *ContentsQuery

func (*ContentsQuery) WithUserID

func (q *ContentsQuery) WithUserID(userID uint) *ContentsQuery

type DBMgr

type DBMgr struct{ DB *gorm.DB }

func NewDBMgr

func NewDBMgr(dbval string) (*DBMgr, error)

func (*DBMgr) AuthTokens

func (mgr *DBMgr) AuthTokens() *AuthTokensQuery

func (*DBMgr) CollectionRefs

func (mgr *DBMgr) CollectionRefs() *CollectionRefsQuery

func (*DBMgr) Collections

func (mgr *DBMgr) Collections() *CollectionsQuery

func (*DBMgr) Contents

func (mgr *DBMgr) Contents() *ContentsQuery

func (*DBMgr) DFERecords

func (mgr *DBMgr) DFERecords() *DFERecordsQuery

func (*DBMgr) Deals

func (mgr *DBMgr) Deals() *DealsQuery

func (*DBMgr) InviteCodes

func (mgr *DBMgr) InviteCodes() *InviteCodesQuery

func (*DBMgr) MinerStorageAsks

func (mgr *DBMgr) MinerStorageAsks() *MinerStorageAsksQuery

func (*DBMgr) ObjRefs

func (mgr *DBMgr) ObjRefs() *ObjRefsQuery

func (*DBMgr) Objects

func (mgr *DBMgr) Objects() *ObjectsQuery

func (*DBMgr) PieceCommRecords

func (mgr *DBMgr) PieceCommRecords() *PieceCommRecordsQuery

func (*DBMgr) ProposalRecords

func (mgr *DBMgr) ProposalRecords() *ProposalRecordsQuery

func (*DBMgr) RetrievalFailureRecords

func (mgr *DBMgr) RetrievalFailureRecords() *RetrievalFailureRecordsQuery

func (*DBMgr) RetrievalSuccessRecords

func (mgr *DBMgr) RetrievalSuccessRecords() *RetrievalSuccessRecordsQuery

func (*DBMgr) Shuttles

func (mgr *DBMgr) Shuttles() *ShuttlesQuery

func (*DBMgr) StorageMiners

func (mgr *DBMgr) StorageMiners() *StorageMinersQuery

func (*DBMgr) Users

func (mgr *DBMgr) Users() *UsersQuery

type DBSortOrder

type DBSortOrder int
const (
	OrderDescending DBSortOrder = 0
	OrderAscending  DBSortOrder = 1
)

type DFERecord

type DFERecord struct {
	gorm.Model

	Miner        string
	DealUUID     string
	Phase        string
	Message      string
	Content      uint `gorm:"index"`
	MinerVersion string
}

type DFERecordsQuery

type DFERecordsQuery struct{ DB *gorm.DB }

func NewDFERecordsQuery

func NewDFERecordsQuery(db *gorm.DB) *DFERecordsQuery

func (*DFERecordsQuery) Count

func (q *DFERecordsQuery) Count() (int64, error)

func (*DFERecordsQuery) WithContent

func (q *DFERecordsQuery) WithContent(contentID uint) *DFERecordsQuery

type Deal

type Deal struct {
	gorm.Model

	Content          uint
	PropCid          util.DbCID
	Miner            string
	DealID           int64
	Failed           bool
	Verified         bool
	FailedAt         time.Time
	DTChan           string
	TransferStarted  time.Time
	TransferFinished time.Time

	OnChainAt time.Time
	SealedAt  time.Time
}

type DealID

type DealID uint

type DealsQuery

type DealsQuery struct{ DB *gorm.DB }

func NewDealsQuery

func NewDealsQuery(db *gorm.DB) *DealsQuery

func (*DealsQuery) Count

func (q *DealsQuery) Count() (int64, error)

func (*DealsQuery) Get

func (q *DealsQuery) Get() (Deal, error)

func (*DealsQuery) GetAll

func (q *DealsQuery) GetAll() ([]Deal, error)

func (*DealsQuery) WithContentID

func (q *DealsQuery) WithContentID(contentID uint) *DealsQuery

func (*DealsQuery) WithContentIDs

func (q *DealsQuery) WithContentIDs(contentIDs []uint) *DealsQuery

func (*DealsQuery) WithDealOnChain

func (q *DealsQuery) WithDealOnChain(valid bool) *DealsQuery

func (*DealsQuery) WithFailed

func (q *DealsQuery) WithFailed(failed bool) *DealsQuery

func (*DealsQuery) WithID

func (q *DealsQuery) WithID(id uint) *DealsQuery

func (*DealsQuery) WithPropCid

func (q *DealsQuery) WithPropCid(propCid gocid.Cid) *DealsQuery

type InviteCode

type InviteCode struct {
	gorm.Model

	Code      string `gorm:"unique"`
	CreatedBy uint
	ClaimedBy uint
}

type InviteCodeID

type InviteCodeID uint

type InviteCodesQuery

type InviteCodesQuery struct{ DB *gorm.DB }

func NewInviteCodesQuery

func NewInviteCodesQuery(db *gorm.DB) *InviteCodesQuery

func (*InviteCodesQuery) Create

func (q *InviteCodesQuery) Create(invite InviteCode) error

func (*InviteCodesQuery) GetClaimedInvites

func (q *InviteCodesQuery) GetClaimedInvites() ([]ClaimedInvite, error)

type MinerStorageAsk

type MinerStorageAsk struct {
	gorm.Model

	Miner         string `gorm:"unique"`
	Price         string
	VerifiedPrice string
	MinPieceSize  abi.PaddedPieceSize
	MaxPieceSize  abi.PaddedPieceSize
}

type MinerStorageAskID

type MinerStorageAskID uint

type MinerStorageAsksQuery

type MinerStorageAsksQuery struct{ DB *gorm.DB }

func NewMinerStorageAsksQuery

func NewMinerStorageAsksQuery(db *gorm.DB) *MinerStorageAsksQuery

type ObjRef

type ObjRef struct {
	ID        ObjRefID `gorm:"primarykey"`
	Content   ContentID
	Object    ObjectID
	Offloaded uint
}

type ObjRefID

type ObjRefID uint

type ObjRefStats

type ObjRefStats struct {
	Bandwidth  int64
	TotalReads int64
}

type ObjRefsQuery

type ObjRefsQuery struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

func NewObjRefsQuery

func NewObjRefsQuery(db *gorm.DB) *ObjRefsQuery

func (*ObjRefsQuery) Delete

func (q *ObjRefsQuery) Delete() error

func (*ObjRefsQuery) GetStats

func (q *ObjRefsQuery) GetStats() (ObjRefStats, error)

func (*ObjRefsQuery) WithContentID

func (q *ObjRefsQuery) WithContentID(contentID uint) *ObjRefsQuery

func (*ObjRefsQuery) WithPinID

func (q *ObjRefsQuery) WithPinID(pinID uint) *ObjRefsQuery

type Object

type Object struct {
	ID         ObjectID   `gorm:"primarykey"`
	Cid        util.DbCID `gorm:"index"`
	Size       int
	Reads      int
	LastAccess time.Time
}

type ObjectID

type ObjectID uint

type ObjectsQuery

type ObjectsQuery struct{ DB *gorm.DB }

func NewObjectsQuery

func NewObjectsQuery(db *gorm.DB) *ObjectsQuery

func (*ObjectsQuery) Count

func (q *ObjectsQuery) Count() (int64, error)

func (*ObjectsQuery) DeleteUnreferenced

func (q *ObjectsQuery) DeleteUnreferenced(ids []uint) error

TODO: simplify by using other abstracted functions instead

func (*ObjectsQuery) Exists

func (q *ObjectsQuery) Exists() (bool, error)

func (*ObjectsQuery) WithCid

func (q *ObjectsQuery) WithCid(cid gocid.Cid) *ObjectsQuery

type PieceCommRecord

type PieceCommRecord struct {
	Data  util.DbCID `gorm:"unique"`
	Piece util.DbCID
	Size  abi.UnpaddedPieceSize
}

type PieceCommRecordsQuery

type PieceCommRecordsQuery struct{ DB *gorm.DB }

func NewPieceCommRecordsQuery

func NewPieceCommRecordsQuery(db *gorm.DB) *PieceCommRecordsQuery

type ProposalRecord

type ProposalRecord struct {
	PropCid util.DbCID
	Data    []byte
}

type ProposalRecordsQuery

type ProposalRecordsQuery struct{ DB *gorm.DB }

func NewProposalRecordsQuery

func NewProposalRecordsQuery(db *gorm.DB) *ProposalRecordsQuery

func (*ProposalRecordsQuery) Get

func (*ProposalRecordsQuery) WithPropCid

func (q *ProposalRecordsQuery) WithPropCid(cid gocid.Cid) *ProposalRecordsQuery

type RetrievalFailureRecord

type RetrievalFailureRecord struct {
	gorm.Model

	Miner   string
	Phase   string
	Message string
	Content ContentID
	Cid     util.DbCID
}

type RetrievalFailureRecordID

type RetrievalFailureRecordID uint

type RetrievalFailureRecordsQuery

type RetrievalFailureRecordsQuery struct{ DB *gorm.DB }

func NewRetrievalFailureRecordsQuery

func NewRetrievalFailureRecordsQuery(db *gorm.DB) *RetrievalFailureRecordsQuery

func (*RetrievalFailureRecordsQuery) Count

type RetrievalSuccessRecord

type RetrievalSuccessRecord struct {
	ID        uint `gorm:"primarykey"`
	CreatedAt time.Time

	Cid   util.DbCID
	Miner string

	Peer         string
	Size         uint64
	DurationMs   int64
	AverageSpeed uint64
	TotalPayment string
	NumPayments  int
	AskPrice     string
}

type RetrievalSuccessRecordID

type RetrievalSuccessRecordID uint

type RetrievalSuccessRecordsQuery

type RetrievalSuccessRecordsQuery struct{ DB *gorm.DB }

func NewRetrievalSuccessRecordsQuery

func NewRetrievalSuccessRecordsQuery(db *gorm.DB) *RetrievalSuccessRecordsQuery

func (*RetrievalSuccessRecordsQuery) Count

type Shuttle

type Shuttle struct {
	gorm.Model

	Handle string `gorm:"unique"`
	Host   string
	PeerID string

	Private bool

	Open bool

	Priority int
}

type ShuttleID

type ShuttleID uint

type ShuttlesQuery

type ShuttlesQuery struct{ DB *gorm.DB }

func NewShuttlesQuery

func NewShuttlesQuery(db *gorm.DB) *ShuttlesQuery

type StorageMiner

type StorageMiner struct {
	gorm.Model

	Address         util.DbAddr `gorm:"unique"`
	Suspended       bool
	SuspendedReason string
	Name            string
	Version         string
	Location        string
	Owner           UserID
}

type StorageMinerID

type StorageMinerID uint

type StorageMinersQuery

type StorageMinersQuery struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

func NewStorageMinersQuery

func NewStorageMinersQuery(db *gorm.DB) *StorageMinersQuery

func (*StorageMinersQuery) Count

func (q *StorageMinersQuery) Count() (int64, error)

func (*StorageMinersQuery) Delete

func (q *StorageMinersQuery) Delete() error

func (*StorageMinersQuery) Get

func (*StorageMinersQuery) GetAll

func (q *StorageMinersQuery) GetAll() ([]StorageMiner, error)

func (*StorageMinersQuery) SetName

func (q *StorageMinersQuery) SetName(name string) error

func (*StorageMinersQuery) WithAddress

func (q *StorageMinersQuery) WithAddress(addr address.Address) *StorageMinersQuery

type User

type User struct {
	gorm.Model

	UUID     string `gorm:"unique"`
	Username string `gorm:"unique"`
	PassHash string

	UserEmail string

	Address util.DbAddr

	Perm  int
	Flags int

	StorageDisabled bool
}

type UserID

type UserID uint

type UsersQuery

type UsersQuery struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

func NewUsersQuery

func NewUsersQuery(db *gorm.DB) *UsersQuery

func (*UsersQuery) Count

func (q *UsersQuery) Count() (int64, error)

func (*UsersQuery) Create

func (q *UsersQuery) Create(user User) error

func (*UsersQuery) Exists

func (q *UsersQuery) Exists() (bool, error)

func (*UsersQuery) ExpectDelete

func (q *UsersQuery) ExpectDelete() error

Errors if none were deleted

func (*UsersQuery) Get

func (q *UsersQuery) Get() (User, error)

func (*UsersQuery) WithID

func (q *UsersQuery) WithID(id uint) *UsersQuery

func (*UsersQuery) WithUsername

func (q *UsersQuery) WithUsername(username string) *UsersQuery

Jump to

Keyboard shortcuts

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