diff --git a/templates/00_struct.tpl b/templates/00_struct.tpl index 585feee..fa674ae 100644 --- a/templates/00_struct.tpl +++ b/templates/00_struct.tpl @@ -17,6 +17,16 @@ type {{$modelName}} struct { {{end -}} } +var {{$modelName}}Columns = struct { + {{range $column := .Table.Columns -}} + {{titleCase $column.Name}} string + {{end -}} +}{ + {{range $column := .Table.Columns -}} + {{titleCase $column.Name}}: "{{$column.Name}}", + {{end -}} +} + {{- if .Table.IsJoinTable -}} {{- else}} // {{$modelNameCamel}}R is where relationships are stored. diff --git a/templates/singleton/boil_table_names.tpl b/templates/singleton/boil_table_names.tpl new file mode 100644 index 0000000..062bcad --- /dev/null +++ b/templates/singleton/boil_table_names.tpl @@ -0,0 +1,9 @@ +var TableNames = struct { + {{range $table := .Tables -}} + {{titleCase $table.Name}} string + {{end -}} +}{ + {{range $table := .Tables -}} + {{titleCase $table.Name}}: "{{$table.Name}}", + {{end -}} +}