Skip to content

Commit

Permalink
refs #60. more flexibility to filter fields with WithTag and WithoutT…
Browse files Browse the repository at this point in the history
…ag in Struct
  • Loading branch information
huandu committed Feb 26, 2023
1 parent 1191d33 commit 8fa20c7
Show file tree
Hide file tree
Showing 5 changed files with 438 additions and 86 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ debug_test

# Mac
.DS_Store

# go work
go.work
go.work.sum
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ We can define a struct type and use field tags to let `Struct` know how to creat
type ATable struct {
Field1 string // If a field doesn't has a tag, use "Field1" as column name in SQL.
Field2 int `db:"field2"` // Use "db" in field tag to set column name used in SQL.
Field3 int64 `db:"field3" fieldtag:"foo,bar"` // Set fieldtag to a field. We can call `WithTag` to change default tag or call methods like `Struct#SelectForTag` to set tag explicitly.
Field3 int64 `db:"field3" fieldtag:"foo,bar"` // Set fieldtag to a field. We can call `WithTag` to include fields with tag or `WithoutTag` to exclude fields with tag.
Field4 int64 `db:"field4" fieldtag:"foo"` // If we use `s.WithTag("foo").Select(table)`, columnes of SELECT are field3 and field4.
Field5 string `db:"field5" fieldas:"f5_alias"` // Use "fieldas" in field tag to set a column alias (AS) used in SELECT.
Ignored int32 `db:"-"` // If we set field name as "-", Struct will ignore it.
Expand Down
Loading

0 comments on commit 8fa20c7

Please sign in to comment.