Amend readme for constants
This commit is contained in:
parent
82e14d2e1a
commit
cc47da44fb
1 changed files with 36 additions and 0 deletions
36
README.md
36
README.md
|
@ -76,6 +76,7 @@ Table of Contents
|
||||||
* [Reload](#reload)
|
* [Reload](#reload)
|
||||||
* [Exists](#exists)
|
* [Exists](#exists)
|
||||||
* [Enums](#enums)
|
* [Enums](#enums)
|
||||||
|
* [Constants](#constants)
|
||||||
* [FAQ](#faq)
|
* [FAQ](#faq)
|
||||||
* [Won't compiling models for a huge database be very slow?](#wont-compiling-models-for-a-huge-database-be-very-slow)
|
* [Won't compiling models for a huge database be very slow?](#wont-compiling-models-for-a-huge-database-be-very-slow)
|
||||||
* [Missing imports for generated package](#missing-imports-for-generated-package)
|
* [Missing imports for generated package](#missing-imports-for-generated-package)
|
||||||
|
@ -1223,6 +1224,41 @@ still be able to use your generated library, and it will still work as expected,
|
||||||
to get the tests to pass in this event is to either use a parsable enum value or use a regular column
|
to get the tests to pass in this event is to either use a parsable enum value or use a regular column
|
||||||
instead of an enum.
|
instead of an enum.
|
||||||
|
|
||||||
|
### Constants
|
||||||
|
|
||||||
|
The models package will also contain some structs that contain all of the table and column
|
||||||
|
names harvested from the database at generation time.
|
||||||
|
|
||||||
|
For table names they're generated under `models.TableNames`:
|
||||||
|
|
||||||
|
```go
|
||||||
|
// Generated code from models package
|
||||||
|
var TableNames = struct {
|
||||||
|
Messages string
|
||||||
|
Purchases string
|
||||||
|
}{
|
||||||
|
Messages: "messages",
|
||||||
|
Purchases: "purchases",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usage example:
|
||||||
|
fmt.Println(models.TableNames.Messages)
|
||||||
|
```
|
||||||
|
|
||||||
|
```go
|
||||||
|
// Generated code from models package
|
||||||
|
var MessageColumns = struct {
|
||||||
|
ID string
|
||||||
|
PurchaseID string
|
||||||
|
}{
|
||||||
|
ID: "id",
|
||||||
|
PurchaseID: "purchase_id",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usage example:
|
||||||
|
fmt.Println(models.MessageColumns.ID)
|
||||||
|
```
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
#### Won't compiling models for a huge database be very slow?
|
#### Won't compiling models for a huge database be very slow?
|
||||||
|
|
Loading…
Reference in a new issue