dbdoc

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TableMockMakeGraphProxyContext = func() (pctx inject.ProxyContext) {
		pctx = tableMockCommonProxyContext
		pctx.MethodName = "MakeGraph"
		return
	}()
	TableMockNewProxyContext = func() (pctx inject.ProxyContext) {
		pctx = tableMockCommonProxyContext
		pctx.MethodName = "New"
		return
	}()
	TableMockResolveProxyContext = func() (pctx inject.ProxyContext) {
		pctx = tableMockCommonProxyContext
		pctx.MethodName = "Resolve"
		return
	}()
	TableMockSetCommentProxyContext = func() (pctx inject.ProxyContext) {
		pctx = tableMockCommonProxyContext
		pctx.MethodName = "SetComment"
		return
	}()
	TableMockSetDescriptionProxyContext = func() (pctx inject.ProxyContext) {
		pctx = tableMockCommonProxyContext
		pctx.MethodName = "SetDescription"
		return
	}()
	TableMockSetMapperProxyContext = func() (pctx inject.ProxyContext) {
		pctx = tableMockCommonProxyContext
		pctx.MethodName = "SetMapper"
		return
	}()
	TableMockSetTypeMapperProxyContext = func() (pctx inject.ProxyContext) {
		pctx = tableMockCommonProxyContext
		pctx.MethodName = "SetTypeMapper"
		return
	}()
	TableMockWriteProxyContext = func() (pctx inject.ProxyContext) {
		pctx = tableMockCommonProxyContext
		pctx.MethodName = "Write"
		return
	}()
)
View Source
var (
	// %s分别是多个子图,边样式和边
	GraphFormat = `` /* 209-byte string literal not displayed */

	EdgeStyleFormat = `edge [ arrowtail=normal, style=dashed, color="#444444" ]
	`
)

dot脚本

Functions

func RegisterProxyMethod added in v0.12.0

func RegisterProxyMethod(pctx inject.ProxyContext, cf inject.CtxFunc)

func Resolve

func Resolve(w io.Writer, v ...any) error

Resolve 解析多个结构体,并将它们写到w

func ResolveGraph

func ResolveGraph(w io.Writer, v ...any) error

ResolveGraph 解析多个结构体,生成图脚本,并将它们写到w

Types

type Field

type Field struct {
	Name        string // 名字
	Type        string // 类型
	Nullable    bool   // 是否可null
	Primary     bool   // 是否主键
	Description string // 描述
	Index              // 索引
	Relation           // 关系
}

Field 字段

func FieldByTag

func FieldByTag(tag reflect.StructTag) Field

FieldByTag 从tag解析field

type ITable added in v0.5.0

type ITable interface {
	MakeGraph() *Table
	New() *Table
	Resolve(v any) *Table
	SetComment(comment string) *Table
	SetDescription(description string) *Table
	SetMapper(f Mapper) *Table
	SetTypeMapper(f Mapper) *Table
	Write(w io.Writer) *Table
}

type Index

type Index struct {
	Name      string  // 名字
	Unique    bool    // 是否唯一索引
	FieldList []Field // 涉及字段
}

Index 索引

type Mapper

type Mapper func(string) string

Mapper 映射函数类型

type Relation

type Relation struct {
	TableName  string // 表名字
	TableField string // 表字段
}

Relation 关系

type Table

type Table struct {
	Name        string  // 名字
	Comment     string  // 注释
	Description string  // 描述
	FieldList   []Field // 字段列表
	IndexList   []Index // 索引列表

	//  er图
	Subgraph string // 子图
	Edge     string // 边
	// contains filtered or unexported fields
}

Table 表

func NewTable

func NewTable() *Table

NewTable 新建表

func (*Table) MakeGraph

func (t *Table) MakeGraph() *Table

MakeGraph 生成图

func (*Table) New

func (t *Table) New() *Table

New 新建

func (*Table) Resolve

func (t *Table) Resolve(v any) *Table

Resolve 解析

func (*Table) SetComment

func (t *Table) SetComment(comment string) *Table

SetComment 设置注释

func (*Table) SetDescription

func (t *Table) SetDescription(description string) *Table

SetDescription 设置描述

func (*Table) SetMapper

func (t *Table) SetMapper(f Mapper) *Table

SetMapper 设置字段名映射方法

func (*Table) SetTypeMapper

func (t *Table) SetTypeMapper(f Mapper) *Table

SetTypeMapper 设置类型映射方法

func (*Table) Write

func (t *Table) Write(w io.Writer) *Table

Write 写入f

type TableMock added in v0.5.0

type TableMock struct {
	MakeGraphFunc func() *Table

	NewFunc func() *Table

	ResolveFunc func(v any) *Table

	SetCommentFunc func(comment string) *Table

	SetDescriptionFunc func(description string) *Table

	SetMapperFunc func(f Mapper) *Table

	SetTypeMapperFunc func(f Mapper) *Table

	WriteFunc func(w io.Writer) *Table
}

func (*TableMock) MakeGraph added in v0.5.0

func (mockRecv *TableMock) MakeGraph() *Table

func (*TableMock) New added in v0.5.0

func (mockRecv *TableMock) New() *Table

func (*TableMock) Resolve added in v0.5.0

func (mockRecv *TableMock) Resolve(v any) *Table

func (*TableMock) SetComment added in v0.5.0

func (mockRecv *TableMock) SetComment(comment string) *Table

func (*TableMock) SetDescription added in v0.5.0

func (mockRecv *TableMock) SetDescription(description string) *Table

func (*TableMock) SetMapper added in v0.5.0

func (mockRecv *TableMock) SetMapper(f Mapper) *Table

func (*TableMock) SetTypeMapper added in v0.5.0

func (mockRecv *TableMock) SetTypeMapper(f Mapper) *Table

func (*TableMock) Write added in v0.5.0

func (mockRecv *TableMock) Write(w io.Writer) *Table

Jump to

Keyboard shortcuts

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