package
0.0.0-20231103123238-49bf83314d38
Repository: https://github.com/daz-3ux/dblog.git
Documentation: pkg.go.dev

# README

store layer

  • 仓库层

开发流程

  • 使用单例工厂模式
  • 创建一个结构体: 用来创建 store 层实例
    • store 建立在 *gorm.DB 之上
  • 创建一个 New 函数: 初始化 store 层实例
  • 创建一个包级别的 store 层变量: 为了方便调用 store 层实例
    • S *datastore
  • 创建一个 sync.Once 变量: 为了避免实例被多次创建,
    • once sync.Once

设计思想

  • store.go 中定义 store 层需要实现的模块
    • user.go 中定义 user 模块需要在 store 层所实现的方法, 并实现
  • 从物理上分割多表的代码实现,使代码更易阅读及维护
  • store 层依赖 *gorm.DB 对象, 因为其是项目无关的,可供第三方引用的动作,所以将其以包的形式放置在 pkg
  • initStore 具体实现放置在 helper.go 之中, 使 main 保持简洁

# Functions

NewMockAIStore creates a new mock instance.
NewMockIStore creates a new mock instance.
NewMockPostStore creates a new mock instance.
NewMockUserStore creates a new mock instance.
NewStore create an instance of type IStore.

# Variables

S global variable used for easy access to the initialized instance of store layer by other packages.

# Structs

MockAIStore is a mock of AIStore interface.
MockAIStoreMockRecorder is the mock recorder for MockAIStore.
MockIStore is a mock of IStore interface.
MockIStoreMockRecorder is the mock recorder for MockIStore.
MockPostStore is a mock of PostStore interface.
MockPostStoreMockRecorder is the mock recorder for MockPostStore.
MockUserStore is a mock of UserStore interface.
MockUserStoreMockRecorder is the mock recorder for MockUserStore.

# Interfaces

No description provided by the author
IStore defines the methods that need to be implemented by the Store layer such as IStore defines Users, Users defines the specific methods.
PostStore defines the methods that need to be implemented by the post model in the store layer.
UserStore defines the methods that need to be implemented by the user model in the store layer.