Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Commit

Permalink
Generate interfaces for tables
Browse files Browse the repository at this point in the history
  • Loading branch information
RadhiFadlillah committed Aug 11, 2021
1 parent c8b7c5e commit 9fe1309
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/templates/interfaces.txt
Expand Up @@ -10,6 +10,23 @@ import (
{{end -}}
)

{{if gt (len .ddlQueries) 0}}
// Interfaces for generated tables.

{{range $query := .ddlQueries -}}
{{if gt (len $query.Columns) 0}}
{{$interfaceName := (print "Itf" (camel $query.TableName)) -}}
// {{$interfaceName}} is interface for table "{{$query.TableName}}".
type {{$interfaceName}} interface {
{{range $col := $query.Columns -}}
{{$funcName := print "Get" (camel $col.Name) -}}
{{$funcName}}() interface{}
{{end -}}
}
{{end}}
{{end}}
{{end}}

{{if gt (len .selectQueries) 0}}
// Interfaces for SELECT queries.

Expand Down

0 comments on commit 9fe1309

Please sign in to comment.