Documentation ¶
Index ¶
- Variables
- type Condition
- type DBManager
- type Direction
- type Organization
- type OrganizationByLegalNameCondition
- type OrganizationField
- type OrganizationOrderBy
- type OrganizationReader
- type OrganizationRepository
- type OrganizationSort
- type OrganizationWriter
- type Pagination
- type Repositories
- type User
- type UserByOrganizationIDCondition
- type UserField
- type UserOrderBy
- type UserReader
- type UserRepository
- type UserSort
- type UserWriter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrOrganizationNotFound = errors.New("organization not found") // Fields. ErrUnknownOrganizationField = errors.New("unknown organization field") // Sort. ErrEmptyOrganizationSortField = errors.New("invalid organization sort field") ErrInvalidOrganizationSortDirection = errors.New("invalid organization sort direction") // Unique constraint errors. ErrConflictOrganizationID = errors.New("unique id conflict") ErrConflictOrganizationLegalName = errors.New("unique legal_name conflict") // Immutable errors. ErrImmutableOrganizationID = errors.New("field id is read-only") ErrImmutableOrganizationCreateTime = errors.New("field create_time is read-only") )
View Source
var ( ErrUserNotFound = errors.New("user not found") // Update. ErrNoUserFieldsToUpdate = errors.New("no fields to update") // Fields. ErrUserUnknownField = errors.New("unknown user field") // sort errors. ErrEmptyUserSortField = errors.New("user field is empty") ErrInvalidUserSortDirection = errors.New("invalid user sort direction") // Unique constraint errors. ErrConflictUserID = errors.New("unique id conflict") ErrConflictUserDisplayName = errors.New("unique display_name conflict") ErrConflictUserEmail = errors.New("unique email conflict") // Immutable errors. ErrImmutableUserID = errors.New("field id is read-only") ErrImmutableUserCreateTime = errors.New("field create_time is read-only") )
Functions ¶
This section is empty.
Types ¶
type DBManager ¶
type DBManager interface { // Op starts a new database operation. Op() Repositories // BeginTX starts a new transaction, performs the repository operations within that transaction, // and commits the transaction if all operations succeed; it rolls back the transaction otherwise. BeginOp(ctx context.Context, operation func(context.Context, Repositories) error) error }
DBManager is a database manager. It is used to manage the repositories.
type Organization ¶
type Organization struct { ID uuid.UUID LegalName string CreateTime time.Time UpdateTime time.Time }
Organization is a organization.
type OrganizationByLegalNameCondition ¶
OrganizationByLegalNameCondition is a search condition for organizations by legal name.
type OrganizationField ¶
type OrganizationField string
const ( OrganizationID OrganizationField = "id" OrganizationLegalName OrganizationField = "legal_name" OrganizationCreateTime OrganizationField = "create_time" OrganizationUpdateTime OrganizationField = "update_time" )
func OrganizationFields ¶
func OrganizationFields() []OrganizationField
OrganizationFields returns all organization fields.
type OrganizationOrderBy ¶
type OrganizationOrderBy []OrganizationSort
func (OrganizationOrderBy) Validate ¶
func (o OrganizationOrderBy) Validate() error
Validate checks if the sort fields are valid.
type OrganizationReader ¶
type OrganizationReader interface { Get(context.Context, uuid.UUID) (*Organization, error) List(context.Context, Pagination, OrganizationOrderBy, ...Condition) ([]*Organization, error) }
type OrganizationRepository ¶
type OrganizationRepository interface { OrganizationReader OrganizationWriter }
type OrganizationSort ¶
type OrganizationSort struct { Field OrganizationField Direction Direction }
OrganizationSort pairs a field with a direction.
type OrganizationWriter ¶
type OrganizationWriter interface { Create(context.Context, *Organization) (*Organization, error) Update(context.Context, *Organization, []OrganizationField) (*Organization, error) Delete(context.Context, uuid.UUID) error }
type Pagination ¶
type Repositories ¶
type Repositories struct { User UserRepository Organization OrganizationRepository }
Repositories is a collection of repositories.
type User ¶
type User struct { ID uuid.UUID OrganizationID uuid.UUID DisplayName string Email string Password string CreateTime time.Time UpdateTime time.Time }
func (*User) FromDomain ¶
FromDomain maps a domain.User to a User.
type UserByOrganizationIDCondition ¶
UserByOrganizationIDCondition is a search condition for users by organization ID.
type UserOrderBy ¶
type UserOrderBy []UserSort
func (UserOrderBy) Validate ¶
func (o UserOrderBy) Validate() error
Validate checks if the sort fields are valid.
type UserReader ¶
type UserRepository ¶
type UserRepository interface { UserReader UserWriter }
UserRepository is a reader and writer for users.
Click to show internal directories.
Click to hide internal directories.