store

package
v0.0.0-...-c0e02ee Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package store defines the storage interface for miniblog.

Index

Constants

This section is empty.

Variables

View Source
var (

	// 全局变量,方便其它包直接调用已初始化好的 S 实例.
	S *datastore
)

Functions

func NewStore

func NewStore(db *gorm.DB) *datastore

NewStore 创建一个 IStore 类型的实例.

Types

type IStore

type IStore interface {
	DB(ctx context.Context) *gorm.DB
	TX(ctx context.Context, fn func(ctx context.Context) error) error

	Users() UserStore
	Posts() PostStore
}

IStore 定义了 Store 层需要实现的方法.

type PostExpansion

type PostExpansion interface{}

PostExpansion defines additional methods for post operations.

type PostStore

type PostStore interface {
	Create(ctx context.Context, obj *model.PostM) error
	Update(ctx context.Context, obj *model.PostM) error
	Delete(ctx context.Context, opts *where.WhereOptions) error
	Get(ctx context.Context, opts *where.WhereOptions) (*model.PostM, error)
	List(ctx context.Context, opts *where.WhereOptions) (int64, []*model.PostM, error)

	PostExpansion
}

PostStore 定义了 post 模块在 store 层所实现的方法.

type UserExpansion

type UserExpansion interface{}

UserExpansion defines additional methods for user operations.

type UserStore

type UserStore interface {
	Create(ctx context.Context, obj *model.UserM) error
	Update(ctx context.Context, obj *model.UserM) error
	Delete(ctx context.Context, opts *where.WhereOptions) error
	Get(ctx context.Context, opts *where.WhereOptions) (*model.UserM, error)
	List(ctx context.Context, opts *where.WhereOptions) (int64, []*model.UserM, error)

	UserExpansion
}

UserStore 定义了 user 模块在 store 层所实现的方法.

Jump to

Keyboard shortcuts

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