package
0.1.1
Repository: https://github.com/dotnetage/go-titan.git
Documentation: pkg.go.dev

# README

Repository 模式

import (
    "go-titan/repository"
)

func main() {
    repos := repository.New(
        repository.WithPostgre(
            DBName("testdb"),
            DBUser("titan"),
            DBPwd("titan"),
        ))
}

建模

titan 的默认使用gorm实现Repository,模型的声明请参考 GORM的声明模型中的内容

由于是通用模型所以对特殊的字段类型建议使用gorm.io/datatypes提供的数据类型。

type ComposeData struct {
	ID     string `gorm:"primaryKey;"`
	Secret []byte
	Tags  []string `gorm:"type:text[]"`
	Metas datatypes.JSON
}

新增

testUser := &UserTest{
		Name:  gofakeit.UserName(),
		Email: gofakeit.Email(),
	}
err = repos.Add(testUser)
require.NoError(t, err)

删除

查询

更新

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author

# Interfaces

DataWorks 统一数据存储对象(UnitOfWorks).
Repository 基于模式定义了通用的数据访问接口,用以解决一般的CRUD问题.

# Type aliases

No description provided by the author