store

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Store 层

因为 Store 代码相对不易变,所以,Store 层很少会随着项目迭代,衍生出 V2 版本,所以 Store 层只需要一个版本即可。

Documentation

Overview

nolint: dupl

Package store defines the storage interface for miniblog.

nolint: dupl

nolint: dupl

Package store is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(NewStore, wire.Bind(new(IStore), new(*datastore)))

ProviderSet is a Wire provider set that declares dependency injection rules. It includes the NewStore constructor function to generate datastore instances. wire.Bind is used to bind the IStore interface to the concrete implementation *datastore, allowing automatic injection of *datastore instances wherever IStore is required.

View Source
var (

	// S is a global variable for convenient access to the initialized datastore
	// instance from other packages.
	S *datastore
)

Functions

func NewStore

func NewStore(db *gorm.DB) *datastore

NewStore initializes a singleton instance of type IStore. It ensures that the datastore is only created once using sync.Once.

Types

type ChainExpansion

type ChainExpansion interface{}

ChainExpansion is an empty interface provided for extending the ChainStore interface. Developers can define chain-specific additional methods in this interface for future expansion.

type ChainStore

type ChainStore interface {
	// Create inserts a new Chain record into the store.
	Create(ctx context.Context, obj *model.ChainM) error

	// Update modifies an existing Chain record in the store based on the given model.
	Update(ctx context.Context, obj *model.ChainM) error

	// Delete removes Chain records that satisfy the given query options.
	Delete(ctx context.Context, opts *where.Options) error

	// Get retrieves a single Chain record that satisfies the given query options.
	Get(ctx context.Context, opts *where.Options) (*model.ChainM, error)

	// List retrieves a list of Chain records and their total count based on the given query options.
	List(ctx context.Context, opts *where.Options) (int64, []*model.ChainM, error)

	// ChainExpansion is a placeholder for extension methods for chains,
	// to be implemented by additional interfaces if needed.
	ChainExpansion
}

ChainStore defines the interface for managing chain-related data operations.

type IStore

type IStore interface {
	// DB returns the *gorm.DB instance of the Store layer, which might be used in rare cases.
	DB(ctx context.Context, wheres ...where.Where) *gorm.DB
	// TX is used to implement transactions in the Biz layer.
	TX(ctx context.Context, fn func(ctx context.Context) error) error
	// Chain returns an implementation of the ChainStore.
	Chain() ChainStore
	// MinerSet returns an implementation of the MinerSetStore.
	MinerSet() MinerSetStore
	// Miner returns an implementation of the MinerStore.
	Miner() MinerStore
}

IStore defines the methods that the Store layer needs to implement.

type MinerExpansion

type MinerExpansion interface{}

MinerExpansion is an empty interface provided for extending the MinerStore interface. Developers can define miner-specific additional methods in this interface for future expansion.

type MinerSetExpansion

type MinerSetExpansion interface{}

MinerSetExpansion is an empty interface provided for extending the MinerSetStore interface. Developers can define minerset-specific additional methods in this interface for future expansion.

type MinerSetStore

type MinerSetStore interface {
	// Create inserts a new MinerSet record into the store.
	Create(ctx context.Context, obj *model.MinerSetM) error

	// Update modifies an existing MinerSet record in the store based on the given model.
	Update(ctx context.Context, obj *model.MinerSetM) error

	// Delete removes MinerSet records that satisfy the given query options.
	Delete(ctx context.Context, opts *where.Options) error

	// Get retrieves a single MinerSet record that satisfies the given query options.
	Get(ctx context.Context, opts *where.Options) (*model.MinerSetM, error)

	// List retrieves a list of MinerSet records and their total count based on the given query options.
	List(ctx context.Context, opts *where.Options) (int64, []*model.MinerSetM, error)

	// MinerSetExpansion is a placeholder for extension methods for minersets,
	// to be implemented by additional interfaces if needed.
	MinerSetExpansion
}

MinerSetStore defines the interface for managing minerset-related data operations.

type MinerStore

type MinerStore interface {
	// Create inserts a new Miner record into the store.
	Create(ctx context.Context, obj *model.MinerM) error

	// Update modifies an existing Miner record in the store based on the given model.
	Update(ctx context.Context, obj *model.MinerM) error

	// Delete removes Miner records that satisfy the given query options.
	Delete(ctx context.Context, opts *where.Options) error

	// Get retrieves a single Miner record that satisfies the given query options.
	Get(ctx context.Context, opts *where.Options) (*model.MinerM, error)

	// List retrieves a list of Miner records and their total count based on the given query options.
	List(ctx context.Context, opts *where.Options) (int64, []*model.MinerM, error)

	// MinerExpansion is a placeholder for extension methods for miners,
	// to be implemented by additional interfaces if needed.
	MinerExpansion
}

MinerStore defines the interface for managing miner-related data operations.

type MockChainStore

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

MockChainStore is a mock of ChainStore interface.

func NewMockChainStore

func NewMockChainStore(ctrl *gomock.Controller) *MockChainStore

NewMockChainStore creates a new mock instance.

func (*MockChainStore) Create

func (m *MockChainStore) Create(arg0 context.Context, arg1 *model.ChainM) error

Create mocks base method.

func (*MockChainStore) Delete

func (m *MockChainStore) Delete(arg0 context.Context, arg1 *where.Options) error

Delete mocks base method.

func (*MockChainStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockChainStore) Get

func (m *MockChainStore) Get(arg0 context.Context, arg1 *where.Options) (*model.ChainM, error)

Get mocks base method.

func (*MockChainStore) List

func (m *MockChainStore) List(arg0 context.Context, arg1 *where.Options) (int64, []*model.ChainM, error)

List mocks base method.

func (*MockChainStore) Update

func (m *MockChainStore) Update(arg0 context.Context, arg1 *model.ChainM) error

Update mocks base method.

type MockChainStoreMockRecorder

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

MockChainStoreMockRecorder is the mock recorder for MockChainStore.

func (*MockChainStoreMockRecorder) Create

func (mr *MockChainStoreMockRecorder) Create(arg0, arg1 interface{}) *gomock.Call

Create indicates an expected call of Create.

func (*MockChainStoreMockRecorder) Delete

func (mr *MockChainStoreMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockChainStoreMockRecorder) Get

func (mr *MockChainStoreMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockChainStoreMockRecorder) List

func (mr *MockChainStoreMockRecorder) List(arg0, arg1 interface{}) *gomock.Call

List indicates an expected call of List.

func (*MockChainStoreMockRecorder) Update

func (mr *MockChainStoreMockRecorder) Update(arg0, arg1 interface{}) *gomock.Call

Update indicates an expected call of Update.

type MockIStore

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

MockIStore is a mock of IStore interface.

func NewMockIStore

func NewMockIStore(ctrl *gomock.Controller) *MockIStore

NewMockIStore creates a new mock instance.

func (*MockIStore) Chain

func (m *MockIStore) Chain() ChainStore

Chain mocks base method.

func (*MockIStore) DB

func (m *MockIStore) DB(arg0 context.Context, arg1 ...where.Where) *gorm.DB

DB mocks base method.

func (*MockIStore) EXPECT

func (m *MockIStore) EXPECT() *MockIStoreMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIStore) Miner

func (m *MockIStore) Miner() MinerStore

Miner mocks base method.

func (*MockIStore) MinerSet

func (m *MockIStore) MinerSet() MinerSetStore

MinerSet mocks base method.

func (*MockIStore) TX

func (m *MockIStore) TX(arg0 context.Context, arg1 func(context.Context) error) error

TX mocks base method.

type MockIStoreMockRecorder

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

MockIStoreMockRecorder is the mock recorder for MockIStore.

func (*MockIStoreMockRecorder) Chain

func (mr *MockIStoreMockRecorder) Chain() *gomock.Call

Chain indicates an expected call of Chain.

func (*MockIStoreMockRecorder) DB

func (mr *MockIStoreMockRecorder) DB(arg0 interface{}, arg1 ...interface{}) *gomock.Call

DB indicates an expected call of DB.

func (*MockIStoreMockRecorder) Miner

func (mr *MockIStoreMockRecorder) Miner() *gomock.Call

Miner indicates an expected call of Miner.

func (*MockIStoreMockRecorder) MinerSet

func (mr *MockIStoreMockRecorder) MinerSet() *gomock.Call

MinerSet indicates an expected call of MinerSet.

func (*MockIStoreMockRecorder) TX

func (mr *MockIStoreMockRecorder) TX(arg0, arg1 interface{}) *gomock.Call

TX indicates an expected call of TX.

type MockMinerSetStore

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

MockMinerSetStore is a mock of MinerSetStore interface.

func NewMockMinerSetStore

func NewMockMinerSetStore(ctrl *gomock.Controller) *MockMinerSetStore

NewMockMinerSetStore creates a new mock instance.

func (*MockMinerSetStore) Create

func (m *MockMinerSetStore) Create(arg0 context.Context, arg1 *model.MinerSetM) error

Create mocks base method.

func (*MockMinerSetStore) Delete

func (m *MockMinerSetStore) Delete(arg0 context.Context, arg1 *where.Options) error

Delete mocks base method.

func (*MockMinerSetStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMinerSetStore) Get

Get mocks base method.

func (*MockMinerSetStore) List

func (m *MockMinerSetStore) List(arg0 context.Context, arg1 *where.Options) (int64, []*model.MinerSetM, error)

List mocks base method.

func (*MockMinerSetStore) Update

func (m *MockMinerSetStore) Update(arg0 context.Context, arg1 *model.MinerSetM) error

Update mocks base method.

type MockMinerSetStoreMockRecorder

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

MockMinerSetStoreMockRecorder is the mock recorder for MockMinerSetStore.

func (*MockMinerSetStoreMockRecorder) Create

func (mr *MockMinerSetStoreMockRecorder) Create(arg0, arg1 interface{}) *gomock.Call

Create indicates an expected call of Create.

func (*MockMinerSetStoreMockRecorder) Delete

func (mr *MockMinerSetStoreMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockMinerSetStoreMockRecorder) Get

func (mr *MockMinerSetStoreMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockMinerSetStoreMockRecorder) List

func (mr *MockMinerSetStoreMockRecorder) List(arg0, arg1 interface{}) *gomock.Call

List indicates an expected call of List.

func (*MockMinerSetStoreMockRecorder) Update

func (mr *MockMinerSetStoreMockRecorder) Update(arg0, arg1 interface{}) *gomock.Call

Update indicates an expected call of Update.

type MockMinerStore

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

MockMinerStore is a mock of MinerStore interface.

func NewMockMinerStore

func NewMockMinerStore(ctrl *gomock.Controller) *MockMinerStore

NewMockMinerStore creates a new mock instance.

func (*MockMinerStore) Create

func (m *MockMinerStore) Create(arg0 context.Context, arg1 *model.MinerM) error

Create mocks base method.

func (*MockMinerStore) Delete

func (m *MockMinerStore) Delete(arg0 context.Context, arg1 *where.Options) error

Delete mocks base method.

func (*MockMinerStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMinerStore) Get

func (m *MockMinerStore) Get(arg0 context.Context, arg1 *where.Options) (*model.MinerM, error)

Get mocks base method.

func (*MockMinerStore) List

func (m *MockMinerStore) List(arg0 context.Context, arg1 *where.Options) (int64, []*model.MinerM, error)

List mocks base method.

func (*MockMinerStore) Update

func (m *MockMinerStore) Update(arg0 context.Context, arg1 *model.MinerM) error

Update mocks base method.

type MockMinerStoreMockRecorder

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

MockMinerStoreMockRecorder is the mock recorder for MockMinerStore.

func (*MockMinerStoreMockRecorder) Create

func (mr *MockMinerStoreMockRecorder) Create(arg0, arg1 interface{}) *gomock.Call

Create indicates an expected call of Create.

func (*MockMinerStoreMockRecorder) Delete

func (mr *MockMinerStoreMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockMinerStoreMockRecorder) Get

func (mr *MockMinerStoreMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockMinerStoreMockRecorder) List

func (mr *MockMinerStoreMockRecorder) List(arg0, arg1 interface{}) *gomock.Call

List indicates an expected call of List.

func (*MockMinerStoreMockRecorder) Update

func (mr *MockMinerStoreMockRecorder) Update(arg0, arg1 interface{}) *gomock.Call

Update indicates an expected call of Update.

Jump to

Keyboard shortcuts

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