model

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentPath

func GetCurrentPath() string

func GetGoType

func GetGoType(exp ast.Expr) string

func GetModuleName

func GetModuleName() (string, string)

func GetRelativePath

func GetRelativePath() string

func GoCamelCase

func GoCamelCase(s string) string

func GoModFilePath

func GoModFilePath() string

func GoTypeToProtoType

func GoTypeToProtoType(g string) string

func GoTypeToTypeScriptDefaultValue

func GoTypeToTypeScriptDefaultValue(g string) string

func GoTypeToWhereFunc added in v1.1.0

func GoTypeToWhereFunc(gt, gn string) string

func Incr

func Incr(x int) int

func IsNumber

func IsNumber(arg string) bool

func JSONCamelCase

func JSONCamelCase(s string) string

JSONCamelCase converts a snake_case identifier to a camelCase identifier, according to the protobuf JSON specification.

func JSONSnakeCase

func JSONSnakeCase(s string) string

JSONSnakeCase converts a camelCase identifier to a snake_case identifier, according to the protobuf JSON specification.

func MysqlToGoFieldType

func MysqlToGoFieldType(dt, ct string) (string, int)

MysqlToGoFieldType MysqlToGoFieldType

func PostgresToGoFieldType added in v1.1.0

func PostgresToGoFieldType(dt, ct string) (string, int)

func SQLTool

func SQLTool(t *Table, flag string) string

SQLTool SQLTool

func Sqlite3ToGoFieldType added in v1.1.0

func Sqlite3ToGoFieldType(dt, ct string) (string, int)

Types

type Column

type Column struct {
	OrdinalPosition           int    // field_ordinal
	ColumnName                string // column_name
	DataType                  string // data_type
	ColumnType                string // column_type
	ColumnComment             string // column_comment,
	NotNull                   bool   // not_null
	IsPrimaryKey              bool   // is_primary_key
	IsAutoIncrment            bool   // is_auto_incrment
	IsDefaultCurrentTimestamp bool   // is_default_currenttimestamp
	GoColumnName              string // go field name
	GoColumnType              string // go field type
	BigType                   int    // 0 表示不生成where 1 表示比较类型 2表示比较类型+字符串 3表示比较类型,修改传入参数
	GoConditionType           string // 生成where 的类型参数
	ProtoType                 string // protoType
}

Column Column

func MysqlColumn

func MysqlColumn(ddl *ast.CreateTableStmt, notint64 bool) ([]*Column, error)

func PostgresColumn added in v1.1.0

func PostgresColumn(ddl *pg_query.CreateStmt, notint64 bool) ([]*Column, error)

func Sqlite3Column added in v1.1.0

func Sqlite3Column(ddl *sql.CreateTableStatement, notint64 bool) ([]*Column, error)

type Document

type Document struct {
	Package       string
	Name          string
	GoName        string
	ImportTime    bool
	Fields        []*Field
	ObjectIDField *Field
}

func ParseMongoStruct

func ParseMongoStruct(filePath, structName string) *Document

type Field

type Field struct {
	Name   string
	GoName string
	GoType string
	Tag    string
}

type PbField

type PbField struct {
	PbName string
	PbType string
	GoName string
	GoType string
}

type PbMessage

type PbMessage struct {
	PbName string
	GoName string
	Fields []*PbField
}

func ParseStruct

func ParseStruct(filePath, structName string) *PbMessage

type Table

type Table struct {
	Database         string
	SchemaName       string    // for pg
	TableName        string    // table name
	GoTableName      string    // go struct name
	PackageName      string    // package name
	Fields           []*Column // columns
	GenerateWhereCol []*Column // GenerateWhereCol 生成where字段比较方法的列
	PrimaryKey       *Column   // primary_key column
	ImportTime       bool      // is need import time
	RelativePath     string
	Protopkg         string
	Dialect          string //mysql postgres sqlite3
}

Table Table

func MysqlTable

func MysqlTable(db, path, relative string, notint64 bool, dialect string) *Table

func PostgresTable added in v1.1.0

func PostgresTable(db, path, relative string, notint64 bool, dialect string) *Table

func Sqlite3Table added in v1.1.0

func Sqlite3Table(db, path, relative string, notint64 bool, dialect string) *Table

Jump to

Keyboard shortcuts

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