From f5e53ac52b49caba35d1b34deea4a040910de226 Mon Sep 17 00:00:00 2001 From: Guy Tish Date: Mon, 26 Jun 2017 14:14:16 +0300 Subject: [PATCH] Added table columns and table names as anonymous struct --- templates/00_struct.tpl | 10 ++++++++++ templates/singleton/boil_table_names.tpl | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 templates/singleton/boil_table_names.tpl 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 -}} +}