naming

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

naming rules that turn a schema into sqlc, proto, sqlc go, proto go, typescript

Index

Constants

View Source
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 AggregateColumn(fn, field string) string

func CreateBulkQueryName

func CreateBulkQueryName(entity string) string

insert many rows

func CreateQueryName

func CreateQueryName(entity string) string

insert one row

func DeleteAllQueryName

func DeleteAllQueryName(entity string) string

delete every row

func DeleteQueryName

func DeleteQueryName(entity string) string

delete by primary key

func GetByQueryName

func GetByQueryName(entity string, fields []string) string

get one row by the given fields

func ListAllQueryName

func ListAllQueryName(entity string, distinct []string) string

list every row. distinct can be empty

func ListByQueryName

func ListByQueryName(entity string, distinct, fields, filters []string) string

list some rows. distinct, fields and filters can be empty

func ParamsName

func ParamsName(query string) string

argument struct sqlc makes sqlc makes it only when the query takes 2 or more arguments

func PascalSuggestion

func PascalSuggestion(name string) string

rewrites letter queue of capitals in one word: HTTPServer -> HttpServer

func ProtocGoName

func ProtocGoName(protoName string) string

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

func QueryWords(fields []string) string

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 RequestName

func RequestName(query string) string

request message of a query

func ReservedSuffixes

func ReservedSuffixes() []string

endings a custom Name() cannot use name ListActive must not give the message ListActiveRequestRequest

func ResponseName

func ResponseName(query string) string

response message of a query a query that returns the entity has no response message

func RowName

func RowName(query string) string

row message of a bulk insert or a multi column distinct

func ServiceName

func ServiceName(entity string) string

service of an entity: MyUser -> MyUserService

func SqlcGoName

func SqlcGoName(sqlName string) string

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 TableName

func TableName(entity string) string

sql table name, MyUser becomes my_user.

func UpdateQueryName

func UpdateQueryName(entity string) string

update by primary key

func ValidateEntityName

func ValidateEntityName(name string) error

func ValidateFieldName

func ValidateFieldName(name string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL