Skip to content

Releases: nvcnvn/sqlc-gen-go-crud

new helper methods for table schema

06 Sep 05:42

Choose a tag to compare

Generate 3 new methods for each struct: TableName, Fields, and FieldsMap

type TestTable struct {
	ID          pgtype.UUID        `json:"id"`
}

func (s *TestTable) TableName() string {
	return "public.test_table"
}

func (s *TestTable) Fields() ([]string, []any) {
	return []string{
			"id",
		}, []any{
			&s.ID,
		}
}

func (s *TestTable) FieldsMap() map[string]any {
	return map[string]any{
		"id":          &s.ID,
	}
}