Documentation
¶
Overview ¶
naming rules that turn a schema into sqlc, proto, sqlc go, proto go, typescript
Index ¶
- Constants
- func AggregateColumn(fn, field string) string
- func CreateBulkQueryName(entity string) string
- func CreateQueryName(entity string) string
- func DeleteAllQueryName(entity string) string
- func DeleteQueryName(entity string) string
- func GetByQueryName(entity string, fields []string) string
- func ListAllQueryName(entity string, distinct []string) string
- func ListByQueryName(entity string, distinct, fields, filters []string) string
- func ParamsName(query string) string
- func PascalSuggestion(name string) string
- func ProtocGoName(protoName string) string
- func QueryWords(fields []string) string
- func RequestName(query string) string
- func ReservedSuffixes() []string
- func ResponseName(query string) string
- func RowName(query string) string
- func ServiceName(entity string) string
- func SqlcGoName(sqlName string) string
- func TableName(entity string) string
- func UpdateQueryName(entity string) string
- func ValidateEntityName(name string) error
- func ValidateFieldName(name string) error
Constants ¶
const ( SuffixService = "Service" SuffixRequest = "Request" SuffixResponse = "Response" SuffixRow = "Row" SuffixParams = "Params" )
suffixes sqlc and proto add to a name kept here because 4 generators used to repeat them
Variables ¶
This section is empty.
Functions ¶
func AggregateColumn ¶
func GetByQueryName ¶
get one row by the given fields
func ListAllQueryName ¶
list every row. distinct can be empty
func ListByQueryName ¶
list some rows. distinct, fields and filters can be empty
func ParamsName ¶
argument struct sqlc makes sqlc makes it only when the query takes 2 or more arguments
func PascalSuggestion ¶
rewrites letter queue of capitals in one word: HTTPServer -> HttpServer
func ProtocGoName ¶
ProtocGoName returns the Go name protoc-gen-go gives a proto field It applies no Go initialisms: sensor_id becomes SensorId and id becomes Id
The body is a copy of google.golang.org/protobuf/internal/strs.GoCamelCase
func QueryWords ¶
field names as the words of a query name: is_active -> IsActive no special words, so org_id -> OrgId a word starting with a digit stays joined, so field_2 -> Field2 ProtocGoName does both of those differently, so this is its own rule
func ReservedSuffixes ¶
func ReservedSuffixes() []string
endings a custom Name() cannot use name ListActive must not give the message ListActiveRequestRequest
func ResponseName ¶
response message of a query a query that returns the entity has no response message
func ServiceName ¶
service of an entity: MyUser -> MyUserService
func SqlcGoName ¶
sqlc lowercases the whole identifier, splits it on underscores and titles each part part equal to id becomes ID, so user_id is UserID.
func ValidateEntityName ¶
func ValidateFieldName ¶
Types ¶
This section is empty.