Documentation ¶
Overview ¶
Package db contains client related CRUD functionality.
Index ¶
- type Client
- type Store
- func (s Store) Create(ctx context.Context, client Client) error
- func (s Store) Delete(ctx context.Context, clientID string) error
- func (s Store) Query(ctx context.Context, userID string, pageNumber int, rowsPerPage int) ([]Client, error)
- func (s Store) QueryByID(ctx context.Context, clientID string) (Client, error)
- func (s Store) QueryUnique(ctx context.Context, name, column, id string) string
- func (s Store) QueryWorkspaceClients(ctx context.Context, workspaceID string, pageNumber, rowsPerPage int) ([]Client, error)
- func (s Store) Tran(tx sqlx.ExtContext) Store
- func (s Store) Update(ctx context.Context, client Client) error
- func (s Store) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ID string `db:"client_id"` Name string `db:"name"` Uid string `db:"uid"` Wid string `db:"wid"` Notes string `db:"notes"` DateCreated time.Time `db:"date_created"` DateUpdated time.Time `db:"date_updated"` }
Client represent the structure we need for moving data between the app and the database.
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) Query ¶
func (s Store) Query(ctx context.Context, userID string, pageNumber int, rowsPerPage int) ([]Client, error)
Query retrieves a list of existing client from the database.
func (Store) QueryUnique ¶
QueryUnique gets the specified project from the database.
func (Store) QueryWorkspaceClients ¶
func (s Store) QueryWorkspaceClients(ctx context.Context, workspaceID string, pageNumber, rowsPerPage int) ([]Client, error)
QueryWorkspaceClients retrieves a list of existing client from the database.
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.
Click to show internal directories.
Click to hide internal directories.