forked from coocood/qbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
36 lines (30 loc) · 1.37 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package db
// A Config is the way you can define defaults for the
// database as far as table, column, foreignkey, and primary
// key naming.
type Config struct {
// A function that would give the default table name for a struct
// in the database, for instance Rails would take in "Post" and
// return "posts"
StructToTable func(structName string) string
// A function to give a default name for a databse column based
// on a struct field
FieldToColumn func(structName, fieldName string) string
// A function that gives a guess as to what the default name
// would be for a foreign key field based on the field name from
// the struct and the struct that was embedded in the larger
// struct
ForeignKeyName func(fieldName string, structName string) string
// The default name for a primary key field, this will turn
// the name of the struct into the primary key name. Note that
// this will return the field name for the struct first, and then
// the database column next
IdName func(structName string) (string, string)
// When timestamping is added, CreatedColumn is the default column
// to set to the current time when creating records in the database
CreatedColumn string
// When timestamping is added, UpdatedColumn is the default column
// to set to the current time when Saving records in the database.
// Update* calls would not update this.
UpdatedColumn string
}