Documentation ¶
Overview ¶
Package db contains project related CRUD functionality.
Index ¶
- type Project
- type Store
- func (s Store) Create(ctx context.Context, project Project) error
- func (s Store) Delete(ctx context.Context, projectID string) error
- func (s Store) QueryByID(ctx context.Context, projectID string) (Project, error)
- func (s Store) QueryClientProjects(ctx context.Context, clientID string, pageNumber, rowsPerPage int) ([]Project, error)
- func (s Store) QueryUnique(ctx context.Context, name, column, id string) string
- func (s Store) QueryUserProjects(ctx context.Context, userID string, pageNumber, rowsPerPage int) ([]Project, error)
- func (s Store) QueryWorkspaceProjects(ctx context.Context, workspaceID string, pageNumber, rowsPerPage int) ([]Project, error)
- func (s Store) Tran(tx sqlx.ExtContext) Store
- func (s Store) Update(ctx context.Context, project Project) 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 Project ¶
type Project struct { ID string `db:"project_id"` Name string `db:"name"` Wid string `db:"wid"` Cid string `db:"cid"` Uid string `db:"uid"` Active bool `db:"active"` IsPrivate bool `db:"is_private"` Billable bool `db:"billable"` AutoEstimates bool `db:"auto_estimates"` EstimatedHours time.Duration `db:"estimated_hours"` DateCreated time.Time `db:"date_created"` DateUpdated time.Time `db:"date_updated"` Rate float32 `db:"rate"` HexColor string `db:"hex_color"` }
Project 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) QueryClientProjects ¶
func (s Store) QueryClientProjects(ctx context.Context, clientID string, pageNumber, rowsPerPage int) ([]Project, error)
QueryClientProjects retrieves a list of existing projects from the database.
func (Store) QueryUnique ¶
QueryUnique gets the specified project from the database.
func (Store) QueryUserProjects ¶
func (s Store) QueryUserProjects(ctx context.Context, userID string, pageNumber, rowsPerPage int) ([]Project, error)
QueryUserProjects retrieves a list of existing projects from the database.
func (Store) QueryWorkspaceProjects ¶
func (s Store) QueryWorkspaceProjects(ctx context.Context, workspaceID string, pageNumber, rowsPerPage int) ([]Project, error)
QueryWorkspaceProjects retrieves a list of existing project 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.