parser

package
v0.1.5-beta Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGoType

func GetGoType(sqlType string) string

GetGoType retorna o tipo Go baseado no tipo SQL

func GetSQLType

func GetSQLType(goType string, driver string) string

GetSQLType retorna o tipo SQL baseado no tipo Go

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase exportada para uso externo

Types

type FieldMetadata

type FieldMetadata struct {
	Name        string
	Type        string
	Writable    []string // POST, PUT, PATCH
	Readable    bool
	Required    bool
	Unique      bool
	PrimaryKey  bool
	AutoInc     bool
	Validations map[string]string
	Relation    *Relation
	JSONTag     string
	GORMTag     string
	Default     string
	Index       bool
	Ignore      bool
	IgnoreWrite bool
	IgnoreRead  bool
}

FieldMetadata contém metadados de um campo do model

func (*FieldMetadata) IsReadable

func (f *FieldMetadata) IsReadable() bool

IsReadable verifica se o campo pode ser lido

func (*FieldMetadata) IsWritableInMethod

func (f *FieldMetadata) IsWritableInMethod(method string) bool

IsWritableInMethod verifica se o campo pode ser escrito no método HTTP especificado

func (*FieldMetadata) ValidateValue

func (f *FieldMetadata) ValidateValue(value interface{}) error

ValidateValue valida um valor baseado nas validações do campo

type ModelMetadata

type ModelMetadata struct {
	Name      string
	Package   string
	TableName string
	Fields    []FieldMetadata
	Imports   []string
}

ModelMetadata contém metadados completos de um model

func ParseModelFile

func ParseModelFile(filePath string) (*ModelMetadata, error)

ParseModelFile lê um arquivo .go e extrai metadata

type Relation

type Relation struct {
	Type       string // hasOne, hasMany, belongsTo, manyToMany
	ForeignKey string
	Through    string
	Model      string
}

Relation representa um relacionamento entre models

Jump to

Keyboard shortcuts

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