Documentation
¶
Overview ¶
Package db contains user related CRUD functionality.
Index ¶
- type Store
- func (s Store) Create(ctx context.Context, user User) error
- func (s Store) QueryByEmail(ctx context.Context, email string) (User, error)
- func (s Store) QueryByID(ctx context.Context, userID string) (User, error)
- func (s Store) Tran(tx sqlx.ExtContext) Store
- func (s Store) Update(ctx context.Context, user User) error
- func (s Store) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the set of APIs for user access.
func NewStore ¶
func NewStore(log *zap.SugaredLogger, db *sqlx.DB) Store
NewStore constructs a data for api access.
func (Store) QueryByEmail ¶
QueryByEmail gets the specified user from the database by email.
func (Store) Tran ¶
func (s Store) Tran(tx sqlx.ExtContext) Store
Tran return new Store with transaction in it.
func (Store) WithinTran ¶
WithinTran runs passed function and do commit/rollback at the end.
type User ¶
type User struct { ID string `db:"user_id"` DefaultWid string `db:"default_wid"` Email string `db:"email"` PasswordHash []byte `db:"password_hash"` FullName string `db:"full_name"` TimeOfDayFormat string `db:"time_of_day_format" ` DateFormat string `db:"date_format" ` BeginningOfWeek int `db:"beginning_of_week"` Language string `db:"language"` ImageURL string `db:"image_url"` DateCreated time.Time `db:"date_created"` DateUpdated time.Time `db:"date_updated"` TimeZone string `db:"timezone"` Invitation pq.StringArray `db:"invitation"` DurationFormat string `db:"duration_format"` }
User represent the structure we need for moving data between the app and the database.
Click to show internal directories.
Click to hide internal directories.