Update wiki pages.
This commit is contained in:
parent
518ff49a77
commit
c78ca8a876
17 changed files with 105 additions and 81 deletions
|
|
@ -1,21 +1,21 @@
|
|||
## Model
|
||||
|
||||
Model files are simple data files used to store result of SQL queries. They are
|
||||
Model files are simple Go struct types used to combine and store result of SQL queries. They are
|
||||
autogenerated from database tables and enums.
|
||||
|
||||
### Table model files
|
||||
|
||||
Following rules are applied to generate model files from database tables:
|
||||
Following rules are applied to generate model types from database tables:
|
||||
|
||||
- for every table there is one Go file generated. File name is in snake case of the table name.
|
||||
- every model file contains one struct type.
|
||||
Type name is a camel case of table name.
|
||||
- for every column of table there is a field in model struct. Field name is camel case of column name.
|
||||
- every model file contains one struct type. Type name is a camel case of table name. Package name
|
||||
is always `model`.
|
||||
- for every column of table there is a field in model struct type. Field name is camel case of column name.
|
||||
See below table for type mapping.
|
||||
- fields are pointer types, if they relate to column that can be NULL.
|
||||
- fields corresponds to primary key columns are tagged with `sql:"primary_key"`.
|
||||
_This tag is used during query execution to group row results into desired arbitrary structure.
|
||||
See more at [Execution](https://github.com/go-jet/jet/wiki/Execution):_
|
||||
See more at [Execution](https://github.com/go-jet/jet/wiki/Execution)_
|
||||
|
||||
|
||||
##### Mappings of database types to Go types
|
||||
|
|
@ -79,12 +79,13 @@ type Address struct {
|
|||
Following rules are applied to generate model files from database enums:
|
||||
|
||||
- for every enum there is one Go file generated. File name is a snake case of enum name.
|
||||
- every file contains one renamed string type. Type name is a camel case of enum name.
|
||||
- every file contains one renamed string type. Type name is a camel case of enum name.
|
||||
Package name is always `model`.
|
||||
Enum type has two helper methods to:
|
||||
- initialize correctly from database query result
|
||||
- easily convert enum to string.
|
||||
- for every enum value there is one constant defined.
|
||||
Name of the constant is in format [camel case of enum_name]_[camel case of enum_value_name].
|
||||
Name of the constant is in format `{CamelCase(enum_name)}_{CamelCase(enum_value_name)}`.
|
||||
|
||||
#### Example
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue