Documentation
¶
Index ¶
- func Combinations(set []string) (subsets [][]string)
- func EntityPrimaryKeys(entity *nemgen.Entity) []*nemgen.Field
- func EscapeValue(sql string) string
- func FieldTypeToMYSQL(f *nemgen.Field) string
- func FieldTypeToPG(f *nemgen.Field) string
- func GenerateFile(ctx context.Context, req *GenerateFileRequest) error
- func MapEntityToTypes(e *nemgen.Entity, projectVersion *nemgen.ProjectVersion, dbType db.DBType) ([]SchemaField, []SchemaIndex, []SchemaConstraint)
- func PrintEntities(message string, entities []*nemgen.Entity)
- func SortStandaloneEntities(pv *nemgen.ProjectVersion)
- func ToCamelCase(str string) string
- type Action
- type ActionResult
- type ConfigValues
- type GenerateDeleteForEntityWithValuesParams
- type GenerateFileRequest
- type GenerateInsertForEntityWithValuesParams
- type GenerateRequest
- type GenerateResponse
- type GenerateStatementResult
- func GenerateDeleteForEntityWithValues(ctx context.Context, params GenerateDeleteForEntityWithValuesParams) (*GenerateStatementResult, error)
- func GenerateInsertForEntityWithValues(ctx context.Context, params GenerateInsertForEntityWithValuesParams) (*GenerateStatementResult, error)
- func GenerateUpdateForEntityWithValues(ctx context.Context, params GenerateUpdateForEntityWithValuesParams) (*GenerateStatementResult, error)
- type GenerateUpdateForEntityWithValuesParams
- type SchemaConstraint
- type SchemaEntity
- func (e SchemaEntity) IsPrimaryKey(fieldIdentifier string) bool
- func (e SchemaEntity) NumOfNonePKFields() int
- func (e SchemaEntity) PrimaryKeysIdentifiers() string
- func (e SchemaEntity) PrimaryKeysWhereClause() string
- func (e SchemaEntity) PrimaryKeysWhereClauseForUpdate() string
- func (e SchemaEntity) PrimaryKeysWhereClauseParam(forGolang bool, update bool) string
- func (e SchemaEntity) PrimaryKeysWhereClauseWithValues(values map[string]string) string
- func (e SchemaEntity) UpdateFields() string
- func (e SchemaEntity) UpdateFieldsParam(forGolang bool, onlyWithValue bool, values map[string]string) string
- func (e SchemaEntity) UpdateFieldsWithValues(values map[string]string) string
- type SchemaField
- type SchemaIndex
- type SchemaSelectStatement
- type SchemaSelectStatementField
- type SchemaTemplate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Combinations ¶
func EscapeValue ¶ added in v1.0.57
func FieldTypeToMYSQL ¶
func FieldTypeToPG ¶
func GenerateFile ¶
func GenerateFile(ctx context.Context, req *GenerateFileRequest) error
func MapEntityToTypes ¶
func MapEntityToTypes(e *nemgen.Entity, projectVersion *nemgen.ProjectVersion, dbType db.DBType) ([]SchemaField, []SchemaIndex, []SchemaConstraint)
func PrintEntities ¶ added in v1.0.42
func SortStandaloneEntities ¶ added in v1.0.41
func SortStandaloneEntities(pv *nemgen.ProjectVersion)
func ToCamelCase ¶ added in v1.0.83
ToCamelCase converts a snake_case identifier to CamelCase while keeping common initialisms (ID, UUID, JSON, URL, HTTP/HTTPS) fully upper-cased, so generated query names match go-code-gen's identifier casing (e.g. FetchProjectByUUID, not FetchProjectByUuid). Mirrors go-code-gen's strings.ToCamelCase.
Types ¶
type Action ¶
type Action string
const ( SelectSimpleAction Action = "select_simple" SelectForIndexedSimpleAction Action = "select_indexed_simple" SelectForIndexedCombinedAction Action = "select_indexed_combined" InsertAction Action = "insert" UpdateAction Action = "update" DeleteAction Action = "delete" CreateAction Action = "create" )
type ActionResult ¶
type ConfigValues ¶
type ConfigValues struct {
DBType db.DBType `json:"db_type"`
Entities []string `json:"entities"`
Actions []Action `json:"actions"`
}
func ConfigValuesFromAny ¶ added in v1.0.1
func ConfigValuesFromAny(any interface{}) (*ConfigValues, error)
type GenerateDeleteForEntityWithValuesParams ¶ added in v1.0.57
type GenerateFileRequest ¶
type GenerateFileRequest struct {
ExecutionUUID string
Configvalues *ConfigValues
Data SchemaTemplate
ActionResults *[]ActionResult
Action Action
// contains filtered or unexported fields
}
type GenerateInsertForEntityWithValuesParams ¶ added in v1.0.57
type GenerateRequest ¶
type GenerateRequest struct {
ExecutionUUID string
ProjectVersion *nemgen.ProjectVersion
Configvalues *ConfigValues
ForGolang bool
}
type GenerateResponse ¶
type GenerateResponse struct {
ExecutionUUID string
WorkingDir string
ZipFile string
Results []ActionResult
}
func GenerateSQL ¶ added in v1.0.4
func GenerateSQL(ctx context.Context, req GenerateRequest) (*GenerateResponse, error)
type GenerateStatementResult ¶ added in v1.0.59
type GenerateStatementResult struct {
SQL string `json:"sql"` // display only
ParametrizedSQL string `json:"parametrized_sql"`
Params []string `json:"params"`
}
func GenerateDeleteForEntityWithValues ¶ added in v1.0.57
func GenerateDeleteForEntityWithValues(ctx context.Context, params GenerateDeleteForEntityWithValuesParams) (*GenerateStatementResult, error)
func GenerateInsertForEntityWithValues ¶ added in v1.0.57
func GenerateInsertForEntityWithValues(ctx context.Context, params GenerateInsertForEntityWithValuesParams) (*GenerateStatementResult, error)
func GenerateUpdateForEntityWithValues ¶ added in v1.0.57
func GenerateUpdateForEntityWithValues(ctx context.Context, params GenerateUpdateForEntityWithValuesParams) (*GenerateStatementResult, error)
type GenerateUpdateForEntityWithValuesParams ¶ added in v1.0.57
type SchemaConstraint ¶
type SchemaConstraint struct {
DBType db.DBType
Name string
Relationship *nemgen.Relationship
TableName string
FromFields []SchemaField
ToFields []SchemaField
HasComma bool
}
contraints
func (SchemaConstraint) ForeignKeyFields ¶
func (sc SchemaConstraint) ForeignKeyFields() string
func (SchemaConstraint) ReferenceFields ¶
func (sc SchemaConstraint) ReferenceFields() string
type SchemaEntity ¶
type SchemaEntity struct {
DBType db.DBType
ForGolang bool
Name string
NameTitle string
PrimaryKeys []string
Fields []SchemaField
Indexes []SchemaIndex
Constraints []SchemaConstraint
SelectStatements []SchemaSelectStatement
}
entity
func MapEntityToSchemaEntity ¶ added in v1.0.57
func MapEntityToSchemaEntity(e *nemgen.Entity, projectVersion *nemgen.ProjectVersion, dbType db.DBType, forGolang bool) (SchemaEntity, error)
func (SchemaEntity) IsPrimaryKey ¶
func (e SchemaEntity) IsPrimaryKey(fieldIdentifier string) bool
func (SchemaEntity) NumOfNonePKFields ¶ added in v1.0.68
func (e SchemaEntity) NumOfNonePKFields() int
func (SchemaEntity) PrimaryKeysIdentifiers ¶
func (e SchemaEntity) PrimaryKeysIdentifiers() string
func (SchemaEntity) PrimaryKeysWhereClause ¶
func (e SchemaEntity) PrimaryKeysWhereClause() string
func (SchemaEntity) PrimaryKeysWhereClauseForUpdate ¶ added in v1.0.68
func (e SchemaEntity) PrimaryKeysWhereClauseForUpdate() string
func (SchemaEntity) PrimaryKeysWhereClauseParam ¶ added in v1.0.59
func (e SchemaEntity) PrimaryKeysWhereClauseParam(forGolang bool, update bool) string
func (SchemaEntity) PrimaryKeysWhereClauseWithValues ¶ added in v1.0.57
func (e SchemaEntity) PrimaryKeysWhereClauseWithValues(values map[string]string) string
func (SchemaEntity) UpdateFields ¶
func (e SchemaEntity) UpdateFields() string
func (SchemaEntity) UpdateFieldsParam ¶ added in v1.0.59
func (SchemaEntity) UpdateFieldsWithValues ¶ added in v1.0.57
func (e SchemaEntity) UpdateFieldsWithValues(values map[string]string) string
type SchemaField ¶
type SchemaField struct {
Name string
NameTitle string
Type string
Field *nemgen.Field
Null string
HasComma bool
Default string
Unique string
}
field
func (SchemaField) Postfix ¶
func (f SchemaField) Postfix() string
type SchemaIndex ¶
type SchemaIndex struct {
DBType db.DBType
Name string
FieldNames map[string]string
Index *nemgen.Index
TypePrefix string
Type string
TypeSort int
HasComma bool
}
index
func (SchemaIndex) FieldNamesIdentifiers ¶
func (i SchemaIndex) FieldNamesIdentifiers() string
type SchemaSelectStatement ¶
type SchemaSelectStatement struct {
Name string
Identifier string
EntityIdentifier string
Fields []SchemaSelectStatementField
CombinedIndexes bool
IsPrimary bool
TimeFields []SchemaField
SortSupported bool
}
select
func ResolveSelectStatements ¶
func ResolveSelectStatements(e *nemgen.Entity, dbType db.DBType) []SchemaSelectStatement
type SchemaSelectStatementField ¶
type SchemaSelectStatementField struct {
Name string
Field SchemaField
IsLast bool
}
type SchemaTemplate ¶
type SchemaTemplate struct {
Entities []SchemaEntity
}
Click to show internal directories.
Click to hide internal directories.