models

package
v0.0.302 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB

Functions

func CheckError

func CheckError(err error)

func CloseDB

func CloseDB()

func ConnectDB

func ConnectDB(userName, password, dbname string)

func ConnectMsSqlServerDB added in v0.0.21

func ConnectMsSqlServerDB(user, password, database string, port string)

func ConnectOracleDB

func ConnectOracleDB(user, password, server, service string, port int)

func ConnectPostgresDB

func ConnectPostgresDB(user, password, dbname, host string, port int)

func GetCSharpDataTypeForMySql

func GetCSharpDataTypeForMySql(dataType string, numericPrecision int) string

func GetCSharpDataTypeForOracle

func GetCSharpDataTypeForOracle(dataType string, numericPrecision int) string

func GetCSharpDataTypeForPostgres

func GetCSharpDataTypeForPostgres(dataType string, numericPrecision int) string

func GetCSharpFirstUnitTestValueForMySql

func GetCSharpFirstUnitTestValueForMySql(dataType string) string

func GetCSharpFirstUnitTestValueForOracle

func GetCSharpFirstUnitTestValueForOracle(dataType string) string

func GetCSharpFirstUnitTestValueForPostgres

func GetCSharpFirstUnitTestValueForPostgres(dataType string) string

func GetCSharpSecondUnitTestValueForMySql

func GetCSharpSecondUnitTestValueForMySql(dataType string) string

func GetCSharpSecondUnitTestValueForOracle

func GetCSharpSecondUnitTestValueForOracle(dataType string) string

func GetCSharpSecondUnitTestValueForPostgres

func GetCSharpSecondUnitTestValueForPostgres(dataType string) string

func GetColumnNames

func GetColumnNames(schema, tableName string) []string

func GetGoDataTypeForMySql

func GetGoDataTypeForMySql(dataType string, numericPrecision int) string

func GetGoDataTypeForOracle

func GetGoDataTypeForOracle(dataType string) string

func GetGoDataTypeForPostgres

func GetGoDataTypeForPostgres(dataType string) string

func GetGoFirstUnitTestValueForMySql

func GetGoFirstUnitTestValueForMySql(dataType string, numericPrecision int) string

func GetGoFirstUnitTestValueForOracle

func GetGoFirstUnitTestValueForOracle(dataType string) string

func GetGoFirstUnitTestValueForPostgres

func GetGoFirstUnitTestValueForPostgres(dataType string) string

func GetGoSecondUnitTestValueForMySql

func GetGoSecondUnitTestValueForMySql(dataType string, numericPrecision int) string

func GetGoSecondUnitTestValueForOracle

func GetGoSecondUnitTestValueForOracle(dataType string) string

func GetGoSecondUnitTestValueForPostgres

func GetGoSecondUnitTestValueForPostgres(dataType string) string

func GetJavaDataTypeForMySql

func GetJavaDataTypeForMySql(dataType string, numericPrecision int) string

func GetJavaDataTypeForOracle

func GetJavaDataTypeForOracle(dataType string, numericPrecision int) string

func GetJavaDataTypeForPostgres

func GetJavaDataTypeForPostgres(dataType string, numericPrecision int) string

func GetJavaFirstUnitTestValueForMySql

func GetJavaFirstUnitTestValueForMySql(dataType string) string

func GetJavaFirstUnitTestValueForOracle

func GetJavaFirstUnitTestValueForOracle(dataType string) string

func GetJavaFirstUnitTestValueForPostgres

func GetJavaFirstUnitTestValueForPostgres(dataType string) string

func GetJavaSecondUnitTestValueForMySql

func GetJavaSecondUnitTestValueForMySql(dataType string) string

func GetJavaSecondUnitTestValueForOracle

func GetJavaSecondUnitTestValueForOracle(dataType string) string

func GetJavaSecondUnitTestValueForPostgres

func GetJavaSecondUnitTestValueForPostgres(dataType string) string

func GetJavascriptDataTypeForMySql

func GetJavascriptDataTypeForMySql(dataType string, numericPrecision int) string

func GetJavascriptDataTypeForOracle

func GetJavascriptDataTypeForOracle(dataType string, numericPrecision int) string

func GetJavascriptDataTypeForPostgres

func GetJavascriptDataTypeForPostgres(dataType string, numericPrecision int) string

func GetJavascriptDefaultValueForMySql

func GetJavascriptDefaultValueForMySql(dataType string, numericPrecision int) string

func GetJavascriptDefaultValueForOracle

func GetJavascriptDefaultValueForOracle(dataType string, numericPrecision int) string

func GetJavascriptDefaultValueForPostgres

func GetJavascriptDefaultValueForPostgres(dataType string, numericPrecision int) string

func GetMssqlIdentityColumns added in v0.0.21

func GetMssqlIdentityColumns(tableName string) []string

func GetMssqlPrimaryKeys added in v0.0.21

func GetMssqlPrimaryKeys(tableName, schema string) []string

func GetPkColumnName

func GetPkColumnName(columnName string, keys []ForeignKey) string

func GetPkTableName

func GetPkTableName(columnName string, keys []ForeignKey) string

func GetPostgresPrimaryKeys

func GetPostgresPrimaryKeys(tableName, schema string) []string

func GetTableNames

func GetTableNames(schema string) []string

func GetTableNamesMssql added in v0.0.21

func GetTableNamesMssql(database string, schema string) []string

func GetTableNamesOracle

func GetTableNamesOracle() []string

func GetTableNamesPostgres

func GetTableNamesPostgres(schema string) []string

func IsColumnForeignKey

func IsColumnForeignKey(columnName string, keys []ForeignKey) bool

func MakeTitle added in v0.0.12

func MakeTitle(s string) string

Types

type Actor

type Actor struct {
	// contains filtered or unexported fields
}

type Column

type Column struct {
	ColumnName, DataType, DatabaseType, TableName, PkTableName, PkColumnName string
	IsPrimaryKey, IsNullable, IsAutoIncrement, IsForeignKey                  bool
	OrdinalPosition, NumericPrecision, NumericScale, CharacterMaximumLength  int
}

func GetColumn

func GetColumn(schema, columnName, tableName string) Column

func GetColumnMssql added in v0.0.21

func GetColumnMssql(columnName, tableName string, primaryKeys []string, identityColumns []string) Column

func GetColumnPostgres

func GetColumnPostgres(schema, columnName, tableName, database string, primaryKeys []string) Column

func GetColumnsOracle

func GetColumnsOracle(tableName, schema string, primaryKeys []OraclePrimaryKey, fks []ForeignKey) []Column

func GetMssqlColumns added in v0.0.21

func GetMssqlColumns(tableName, schema, database string, fks []ForeignKey) []Column

func GetPostgresColumns

func GetPostgresColumns(tableName, schema, database string, fks []ForeignKey) []Column

func NewColumn

func NewColumn(columnName, databaseType, tableName string) Column

func (*Column) GetAspNetRouteConstraintType

func (c *Column) GetAspNetRouteConstraintType() string

func (*Column) GetCSharpDataType

func (c *Column) GetCSharpDataType() string

func (*Column) GetCSharpFirstUnitTestValue

func (c *Column) GetCSharpFirstUnitTestValue() string

func (*Column) GetCSharpFirstUnitTestValueFromFile

func (c *Column) GetCSharpFirstUnitTestValueFromFile(valuesFile string) string

func (*Column) GetCSharpSecondUnitTestValue

func (c *Column) GetCSharpSecondUnitTestValue() string

func (*Column) GetCSharpSecondUnitTestValueFromFile

func (c *Column) GetCSharpSecondUnitTestValueFromFile(valuesFile string) string

func (*Column) GetCamelCaseColumnName

func (c *Column) GetCamelCaseColumnName() string

func (*Column) GetColumnNameInCase added in v0.0.301

func (c *Column) GetColumnNameInCase(caseToReturn string) string

func (*Column) GetColumnTableNameInCase added in v0.0.301

func (c *Column) GetColumnTableNameInCase(caseToReturn string) string

func (*Column) GetGoDataType

func (c *Column) GetGoDataType() string

func (*Column) GetGoFirstUnitTestValue

func (c *Column) GetGoFirstUnitTestValue() string

func (*Column) GetGoSecondUnitTestValue

func (c *Column) GetGoSecondUnitTestValue() string

func (*Column) GetJavaDataType

func (c *Column) GetJavaDataType() string

func (*Column) GetJavaFirstUnitTestValue

func (c *Column) GetJavaFirstUnitTestValue() string

func (*Column) GetJavaFirstUnitTestValueAsString added in v0.0.19

func (c *Column) GetJavaFirstUnitTestValueAsString() string

func (*Column) GetJavaFirstUnitTestValueFromFile

func (c *Column) GetJavaFirstUnitTestValueFromFile(valuesFile string) string

func (*Column) GetJavaSecondUnitTestValue

func (c *Column) GetJavaSecondUnitTestValue() string

func (*Column) GetJavaSecondUnitTestValueAsString added in v0.0.19

func (c *Column) GetJavaSecondUnitTestValueAsString() string

func (*Column) GetJavaSecondUnitTestValueFromFile

func (c *Column) GetJavaSecondUnitTestValueFromFile(valuesFile string) string

func (*Column) GetJavascriptDataType

func (c *Column) GetJavascriptDataType() string

func (*Column) GetJavascriptDefaultValue

func (c *Column) GetJavascriptDefaultValue() string

func (*Column) GetPascalCaseColumnName

func (c *Column) GetPascalCaseColumnName() string

func (*Column) GetPascalCaseTableName

func (c *Column) GetPascalCaseTableName() string

func (*Column) GetSetString

func (c *Column) GetSetString() string

func (*Column) GetSetStringJson

func (c *Column) GetSetStringJson() string

func (*Column) GetTitleCaseColumnName added in v0.0.12

func (c *Column) GetTitleCaseColumnName() string

func (*Column) GetTitleCaseTableName added in v0.0.12

func (c *Column) GetTitleCaseTableName() string

func (*Column) IsBinary

func (c *Column) IsBinary() bool

func (*Column) IsGoIntFamilyType added in v0.0.9

func (c *Column) IsGoIntFamilyType() bool

func (*Column) Test

func (c *Column) Test() string

type ForeignKey

type ForeignKey struct {
	ConstraintName, FkTableName, FkColumnName, PkTableName, PkColumnName, Relation string
	FkColumn, PkColumn                                                             Column
}

func GetForeignKeys

func GetForeignKeys(database, tableName string) []ForeignKey

func GetMssqlForeignKeys added in v0.0.21

func GetMssqlForeignKeys(tableName string, primaryKeys []string, identityColumns []string) []ForeignKey

func GetMssqlReferencedForeignKeys added in v0.0.21

func GetMssqlReferencedForeignKeys(tableName string, primaryKeys []string, identityColumns []string) []ForeignKey

func GetOracleForeignKeys

func GetOracleForeignKeys(tableName, schema string) []ForeignKey

func GetOracleReferencedForeignKeys

func GetOracleReferencedForeignKeys(tableName, schema string) []ForeignKey

func GetPostgresForeignKeys

func GetPostgresForeignKeys(schema, database, tableName string, primaryKeys []string) []ForeignKey

func GetPostgresReferencedForeignKeys

func GetPostgresReferencedForeignKeys(schema, database, tableName string, primaryKeys []string) []ForeignKey

func GetReferencedForeignKeys

func GetReferencedForeignKeys(database, tableName string) []ForeignKey

func NewForeignKey

func NewForeignKey(constraintName, fkTableName, fkColumnName,
	pkTableName, pkColumnName string) ForeignKey

func (*ForeignKey) GetCamelCaseFKColumnName

func (f *ForeignKey) GetCamelCaseFKColumnName() string

func (*ForeignKey) GetCamelCaseFKTableName

func (f *ForeignKey) GetCamelCaseFKTableName() string

func (*ForeignKey) GetCamelCaseFKTableNamePlural

func (f *ForeignKey) GetCamelCaseFKTableNamePlural() string

func (*ForeignKey) GetCamelCasePKColumnName

func (f *ForeignKey) GetCamelCasePKColumnName() string

func (*ForeignKey) GetCamelCasePKTableName

func (f *ForeignKey) GetCamelCasePKTableName() string

func (*ForeignKey) GetCamelCasePKTableNamePlural

func (f *ForeignKey) GetCamelCasePKTableNamePlural() string

func (*ForeignKey) GetFKTableNamePluralInCase added in v0.0.301

func (f *ForeignKey) GetFKTableNamePluralInCase() string

func (*ForeignKey) GetFkColumnNameInCase added in v0.0.301

func (f *ForeignKey) GetFkColumnNameInCase(caseToReturn string) string

func (*ForeignKey) GetFkTableNameInCase added in v0.0.301

func (f *ForeignKey) GetFkTableNameInCase(caseToReturn string) string

func (*ForeignKey) GetPascalCaseFKColumnName

func (f *ForeignKey) GetPascalCaseFKColumnName() string

func (*ForeignKey) GetPascalCaseFKTableName

func (f *ForeignKey) GetPascalCaseFKTableName() string

func (*ForeignKey) GetPascalCaseFKTableNamePlural

func (f *ForeignKey) GetPascalCaseFKTableNamePlural(caseToReturn string) string

func (*ForeignKey) GetPascalCasePKColumnName

func (f *ForeignKey) GetPascalCasePKColumnName() string

func (*ForeignKey) GetPascalCasePKTableName

func (f *ForeignKey) GetPascalCasePKTableName() string

func (*ForeignKey) GetPascalCasePKTableNamePlural

func (f *ForeignKey) GetPascalCasePKTableNamePlural() string

func (*ForeignKey) GetPkColumnNameInCase added in v0.0.301

func (f *ForeignKey) GetPkColumnNameInCase(caseToReturn string) string

type GuiEdit

type GuiEdit struct {
	Columns []GuiListColumn `json:"columns"`
}

type GuiList

type GuiList struct {
	FirstColumn GuiListColumn   `json:"firstColumn"`
	Columns     []GuiListColumn `json:"columns"`
}

type GuiListColumn

type GuiListColumn struct {
	ColumnName      string `json:"columnName"`
	Title           string `json:"title"`
	Value           string `json:"value"`
	GuiControl      string `json:"guiControl"`
	SelectOptions   string `json:"selectOptions"`
	SelectKey       string `json:"selectKey"`
	SelectValue     string `json:"selectValue"`
	SelectTableName string `json:"selectTableName"`
}

type GuiListTable

type GuiListTable struct {
	TableName          string  `json:"tableName"`
	AllowAttachedFiles bool    `json:"allowAttachedFiles"`
	GuiList            GuiList `json:"list"`
	GuiEdit            GuiEdit `json:"edit"`
}

func (*GuiListTable) GetEditGuiControlForColumn

func (t *GuiListTable) GetEditGuiControlForColumn(columnName string) string

func (*GuiListTable) GetEditSelectKeyForColumn

func (t *GuiListTable) GetEditSelectKeyForColumn(columnName string) string

func (*GuiListTable) GetEditSelectValueForColumn

func (t *GuiListTable) GetEditSelectValueForColumn(columnName string) string

func (*GuiListTable) HasGuiControl

func (t *GuiListTable) HasGuiControl(controlName string) bool

type GuiListTables

type GuiListTables struct {
	Tables []GuiListTable `json:"tables"`
}

func ReadGuiTables

func ReadGuiTables(templateFile string) GuiListTables

type IntegrationTestSettings

type IntegrationTestSettings struct {
	PostgresUser, PostgresPassword, PostgresDbName, PostgresHost string
	PostgresPort                                                 int
	MySqlUser, MySqlPassword, MySqlDB                            string
}

func ReadIntegrationTestSettings

func ReadIntegrationTestSettings(contextFile string) IntegrationTestSettings

type MySqlColumn

type MySqlColumn struct {
	OrdinalPosition                          int
	NumericPrecision, CharacterMaximumLength *int
	IsNullable, DataType, Extra, ColumnKey   string
}

type MySqlForeignKey

type MySqlForeignKey struct {
	TableName, ColumnName, ConstraintName, ReferencedColumnName, ReferencedTableName string
}

type OracleColumn

type OracleColumn struct {
	ColumnName, Nullable, DataType, IdentityColumn, DataDefault sql.NullString
	DataPrecision, DataLength, DataScale                        sql.NullInt64
}

type OraclePrimaryKey

type OraclePrimaryKey struct {
	TableName, TableSchema, ConstraintName, Status, ColumnName string
	OrdinalPosition                                            int
}

func GetOraclePrimaryKeys

func GetOraclePrimaryKeys(tableName, schema string) []OraclePrimaryKey

type OrmColumn added in v0.0.301

type OrmColumn struct {
	ColumnName, OrmType, DatabaseType, PropertyName string
	IsPrimaryKey, IsNullable, IsAutoIncrement       bool
}

OrmColumn represents a database column with metadata for ORM transformations. It includes details such as column name, data types, property name, and constraints.

func (*OrmColumn) GetColumnNameInCase added in v0.0.301

func (c *OrmColumn) GetColumnNameInCase(caseToReturn string) string

GetColumnNameInCase returns the column name formatted in the specified case style (e.g., camel, snake, kebab, pascal).

func (*OrmColumn) GetPropertyNameInCase added in v0.0.301

func (c *OrmColumn) GetPropertyNameInCase(caseToReturn string) string

GetPropertyNameInCase returns the PropertyName of the OrmColumn converted to the specified case format.

type OrmModel added in v0.0.301

type OrmModel struct {
	TableName, ModelName, Orm string
	Columns                   []OrmColumn
}

OrmModel represents a database model with metadata for ORM transformations, including table and column details.

func ReadModels added in v0.0.21

func ReadModels(modelFile string) []OrmModel

ReadModels reads a JSON file containing ORM model definitions and unmarshals it into a slice of OrmModel.

func (*OrmModel) GetModelNameInCase added in v0.0.301

func (m *OrmModel) GetModelNameInCase(caseToReturn string) string

GetModelNameInCase returns the ModelName of the OrmModel converted to the specified case format.

func (*OrmModel) GetModelNamePluralInCase added in v0.0.302

func (m *OrmModel) GetModelNamePluralInCase(caseToReturn string) string

GetModelNamePluralInCase ensures model name is pluralized in the case that is passed.

func (*OrmModel) GetModelTableNameInCase added in v0.0.301

func (m *OrmModel) GetModelTableNameInCase(caseToReturn string) string

GetModelTableNameInCase returns the TableName of the OrmModel converted to the specified case format.

func (*OrmModel) GetPrimaryModelColumns added in v0.0.302

func (m *OrmModel) GetPrimaryModelColumns() []OrmColumn

func (*OrmModel) HasCompositePrimaryKey added in v0.0.302

func (m *OrmModel) HasCompositePrimaryKey() bool

type PostgresColumn

type PostgresColumn struct {
	OrdinalPosition                                        int
	NumericPrecision, CharacterMaximumLength, NumericScale *int
	IsNullable, DataType, IsIdentity, ColumnDefault        sql.NullString
}

type PostgresPrimaryKey

type PostgresPrimaryKey struct {
	TableName, TableSchema, ConstraintName, ColumnName string
	OrdinalPosition                                    int
}

type Table

type Table struct {
	TableName, DatabaseType string
	Columns                 []Column
	ForeignKeys             []ForeignKey
	ReferencedForeignKeys   []ForeignKey
	GuiListTable            GuiListTable
}

Table represents the structure of a database table, including its name, type, columns, and foreign key relationships.

func GetMssqlTables added in v0.0.21

func GetMssqlTables(schema, database string) []Table

func GetOracleTables

func GetOracleTables(schema string) []Table

func GetPostgresTables

func GetPostgresTables(schema, database string) []Table

func GetTables

func GetTables(schema string) []Table

func NewTable

func NewTable(tableName, databaseType string) Table

NewTable creates and returns a new Table instance with the specified table name and database type.

func ReadTables

func ReadTables(templateFile string) []Table

ReadTables reads a JSON file specified by templateFile and unmarshals its content into a slice of Table structs.

func (*Table) AddColumn

func (t *Table) AddColumn(column Column)

AddColumn adds a new column to the table by appending it to the Columns slice.

func (*Table) GetCSharpFirstPrimaryUnitTestValue

func (t *Table) GetCSharpFirstPrimaryUnitTestValue() string

GetCSharpFirstPrimaryUnitTestValue retrieves the first unit test value of the primary key column from the table.

func (*Table) GetCSharpSecondPrimaryUnitTestValue

func (t *Table) GetCSharpSecondPrimaryUnitTestValue() string

GetCSharpSecondPrimaryUnitTestValue iterates through table columns to return the second primary key's unit test value in C#.

func (*Table) GetCamelCaseTableName

func (t *Table) GetCamelCaseTableName() string

GetCamelCaseTableName converts the table's name to camel case format and returns it as a string.

func (*Table) GetCamelCaseTableNameEF

func (t *Table) GetCamelCaseTableNameEF() string

GetCamelCaseTableNameEF returns the table name in camelCase format, singularized if it is in plural form.

func (*Table) GetCamelCaseTableNamePlural

func (t *Table) GetCamelCaseTableNamePlural() string

GetCamelCaseTableNamePlural converts the table name to camel case and ensures it is pluralized.

func (*Table) GetColumnListWithCSharpTypes

func (t *Table) GetColumnListWithCSharpTypes() string

GetColumnListWithCSharpTypes generates a formatted string listing column names and their C# data types from the table.

func (*Table) GetFirstPrimaryColumn

func (t *Table) GetFirstPrimaryColumn() Column

GetFirstPrimaryColumn returns the first column marked as a primary key within the table. Returns an empty Column if none found.

func (*Table) GetFirstPrimaryColumnCamelCaseColumnName added in v0.0.18

func (t *Table) GetFirstPrimaryColumnCamelCaseColumnName() string

GetFirstPrimaryColumnCamelCaseColumnName retrieves the camel case name of the first primary key column in the table.

func (*Table) GetFirstPrimaryColumnJavaDataType added in v0.0.18

func (t *Table) GetFirstPrimaryColumnJavaDataType() string

GetFirstPrimaryColumnJavaDataType returns the Java data type of the first primary key column in the table. If none, returns empty string.

func (*Table) GetFirstPrimaryColumnJavaFirstUnitTestValue added in v0.0.19

func (t *Table) GetFirstPrimaryColumnJavaFirstUnitTestValue() string

GetFirstPrimaryColumnJavaFirstUnitTestValue returns the Java first unit test value of the first primary key column in the table.

func (*Table) GetFirstPrimaryColumnJavaSecondUnitTestValue added in v0.0.19

func (t *Table) GetFirstPrimaryColumnJavaSecondUnitTestValue() string

GetFirstPrimaryColumnJavaSecondUnitTestValue retrieves the second unit test value of the first primary key column in the table.

func (*Table) GetFirstPrimaryColumnPascalCaseColumnName added in v0.0.18

func (t *Table) GetFirstPrimaryColumnPascalCaseColumnName() string

GetFirstPrimaryColumnPascalCaseColumnName returns the PascalCase name of the first primary key column in the table.

func (*Table) GetFirstPrimaryColumnSetString added in v0.0.19

func (t *Table) GetFirstPrimaryColumnSetString() string

GetFirstPrimaryColumnSetString retrieves the set string of the first primary key column in the table, if one exists.

func (*Table) GetFirstPrimarySetString added in v0.0.19

func (t *Table) GetFirstPrimarySetString() string

GetFirstPrimarySetString returns the modified set string of the first column marked as a primary key in the table.

func (*Table) GetFkTableNameForColumn

func (t *Table) GetFkTableNameForColumn(columnName string) string

GetFkTableNameForColumn returns the primary key table name associated with the given foreign key column name.

func (*Table) GetJavaFirstPrimaryUnitTestValue

func (t *Table) GetJavaFirstPrimaryUnitTestValue() string

GetJavaFirstPrimaryUnitTestValue returns the first unit test value of the primary key column in Java format for the table.

func (*Table) GetJavaFirstPrimaryUnitTestValueAsString added in v0.0.19

func (t *Table) GetJavaFirstPrimaryUnitTestValueAsString() string

GetJavaFirstPrimaryUnitTestValueAsString returns the first Java unit test string value of the primary key in the table.

func (*Table) GetJavaSecondPrimaryUnitTestValue

func (t *Table) GetJavaSecondPrimaryUnitTestValue() string

GetJavaSecondPrimaryUnitTestValue returns the second primary key's unit test value as a string from the table's columns.

func (*Table) GetJavaSecondPrimaryUnitTestValueAsString added in v0.0.19

func (t *Table) GetJavaSecondPrimaryUnitTestValueAsString() string

GetJavaSecondPrimaryUnitTestValueAsString returns the second primary unit test value for a column as a modified string.

func (*Table) GetNullableColumns

func (t *Table) GetNullableColumns() []Column

GetNullableColumns returns a slice of columns that are marked as nullable in the table.

func (*Table) GetPascalCaseTableName

func (t *Table) GetPascalCaseTableName() string

GetPascalCaseTableName returns the table name converted to PascalCase format.

func (*Table) GetPascalCaseTableNameEF

func (t *Table) GetPascalCaseTableNameEF() string

GetPascalCaseTableNameEF converts the table name to PascalCase format and ensures it's singular if it is plural.

func (*Table) GetPascalCaseTableNamePlural

func (t *Table) GetPascalCaseTableNamePlural() string

GetPascalCaseTableNamePlural returns the table name in PascalCase format, ensuring the name is pluralized.

func (*Table) GetPrimaryColumnJavaTypesAndVariables added in v0.0.17

func (t *Table) GetPrimaryColumnJavaTypesAndVariables() string

GetPrimaryColumnJavaTypesAndVariables returns a string containing Java types and variables for primary key columns. The returned string is formatted as "Type1 var1, Type2 var2" for all primary key columns in the table.

func (*Table) GetPrimaryColumnVariables added in v0.0.17

func (t *Table) GetPrimaryColumnVariables() string

GetPrimaryColumnVariables returns a comma-separated string of camel case names for all primary key columns in the table.

func (*Table) GetPrimaryColumns

func (t *Table) GetPrimaryColumns() []Column

GetPrimaryColumns returns a slice of Column objects that are marked as primary keys from the table's columns.

func (*Table) GetPrimaryNonDateColumns added in v0.0.20

func (t *Table) GetPrimaryNonDateColumns() []Column

GetPrimaryNonDateColumns retrieves all primary key columns from the table that are not of "Date" or "Timestamp" type.

func (*Table) GetTableName

func (t *Table) GetTableName() string

GetTableName returns the name of the table associated with the Table instance.

func (*Table) GetTableNameInCase added in v0.0.301

func (t *Table) GetTableNameInCase(caseToReturn string) string

func (*Table) HasAnyDateColumn added in v0.0.17

func (t *Table) HasAnyDateColumn() bool

HasAnyDateColumn checks if the table contains at least one column with a date-related data type such as date, datetime, year, or timestamp.

func (*Table) HasAutoIncrementColumn

func (t *Table) HasAutoIncrementColumn() bool

HasAutoIncrementColumn checks if the table contains at least one column with the auto-increment property.

func (*Table) HasCompositePrimaryKey

func (t *Table) HasCompositePrimaryKey() bool

HasCompositePrimaryKey checks if the table has a composite primary key by verifying if it has more than one primary column.

func (*Table) HasDateColumn

func (t *Table) HasDateColumn() bool

HasDateColumn checks if the table contains at least one column with a "date" data type and returns true if found.

func (*Table) HasDateTimeColumn added in v0.0.17

func (t *Table) HasDateTimeColumn() bool

HasDateTimeColumn checks if the table contains at least one column with the "datetime" data type. Returns true if found.

func (*Table) HasJavaTypeColumn added in v0.0.17

func (t *Table) HasJavaTypeColumn(javaType string) bool

HasJavaTypeColumn checks if the table contains a column with the specified Java data type.

func (*Table) HasJavascriptNumberColumn

func (t *Table) HasJavascriptNumberColumn() bool

HasJavascriptNumberColumn checks if the table has at least one column with the JavaScript data type "Number".

func (*Table) HasJavascriptStringColumn

func (t *Table) HasJavascriptStringColumn() bool

HasJavascriptStringColumn checks if the table contains at least one column with a JavaScript data type of "String".

func (*Table) HasTimestampColumn added in v0.0.17

func (t *Table) HasTimestampColumn() bool

HasTimestampColumn checks if the table contains at least one column with the "timestamp" data type. Returns true if found.

func (*Table) HasYearColumn added in v0.0.17

func (t *Table) HasYearColumn() bool

HasYearColumn checks if the table contains at least one column with a data type of "year".

type Tag

type Tag struct {
	TagName string `json:"tagName"`
	Value   string `json:"value"`
}

func NewTag

func NewTag(tagName, value string) Tag

type Template

type Template struct {
	TemplateFile        string `json:"templateFile"`
	GeneratedFileName   string `json:"generatedFileName"`
	GeneratedFolderName string `json:"generatedFolderName"`
	OutputPath          string `json:"outputPath"`

	AppendFile         bool   `json:"appendFile"`
	OverwriteFile      bool   `json:"overwriteFile"`
	UnitTestJsonJava   string `json:"unitTestJsonJava"`
	UnitTestJsonCSharp string `json:"UnitTestJsonCSharp"`
	ForeignKeyMapping  string `json:"foreignKeyMapping"`

	MinimumGeneratedFileLength int  `json:"minimumGeneratedFileLength"`
	CopyOnly                   bool `json:"copyOnly"`
}

func NewTemplate

func NewTemplate(templateFile, generatedFileName, generatedFolderName, outputPath string) Template

type Templates

type Templates struct {
	Templates     []Template `json:"templates"`
	Tags          []Tag      `json:"tags"`
	IgnoreTables  []string   `json:"ignoreTables"`
	IncludeTables []string   `json:"includeTables"`
}

func ReadTemplates

func ReadTemplates(templateFile string) Templates

type UnitTestValue

type UnitTestValue struct {
	FirstUnitTestValue  string `json:"firstUnitTestValue"`
	SecondUnitTestValue string `json:"secondUnitTestValue"`
}

type UnitTestValueColumn

type UnitTestValueColumn struct {
	ColumnName     string          `json:"columnName"`
	UnitTestValues []UnitTestValue `json:"unitTestValues"`
}

type UnitTestValueTable

type UnitTestValueTable struct {
	TableName string                `json:"tableName"`
	Columns   []UnitTestValueColumn `json:"columns"`
}

type UnitTestValueTables

type UnitTestValueTables struct {
	Tables []UnitTestValueTable `json:"tables"`
}

func ReadUnitTestValues

func ReadUnitTestValues(unitTestFile string) UnitTestValueTables

Jump to

Keyboard shortcuts

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