update documentation with examples of non-persisted fields

This commit is contained in:
Jeremy Stone
2022-03-08 08:31:18 -07:00
committed by Michal Jan Matczuk
parent c965fdf183
commit 2ac4afd7d5

View File

@@ -53,11 +53,13 @@ var personTable = table.New(personMetadata)
// Person represents a row in person table. // Person represents a row in person table.
// Field names are converted to camel case by default, no need to add special tags. // Field names are converted to camel case by default, no need to add special tags.
// If you want to disable a field add `db:"-"` tag, it will not be persisted. // A field will not be persisted by adding the `db:"-"` tag or making it unexported.
type Person struct { type Person struct {
FirstName string FirstName string
LastName string LastName string
Email []string Email []string
HairColor string `db:"-"` // exported and skipped
eyeColor string // unexported also skipped
} }
``` ```
@@ -68,6 +70,8 @@ p := Person{
"Michał", "Michał",
"Matczuk", "Matczuk",
[]string{"michal@scylladb.com"}, []string{"michal@scylladb.com"},
"red", // not persisted
"hazel" // not persisted
} }
q := session.Query(personTable.Insert()).BindStruct(p) q := session.Query(personTable.Insert()).BindStruct(p)
if err := q.ExecRelease(); err != nil { if err := q.ExecRelease(); err != nil {