Documentation
¶
Overview ¶
Package basic is a compiling Phase 1 example application model.
Index ¶
- Variables
- func NewAccountFactory(accounts *repository.Repository[Account]) (*factory.Factory[Account], error)
- func NewAccountResource(accounts *repository.Repository[Account]) (...)
- func NewProjectFactory(projects *repository.Repository[Project], accountID uuid.UUID, ...) (*factory.Factory[Project], error)
- func NewProjectResource(projects *repository.Repository[Project]) (...)
- func NewUserFactory(users *repository.Repository[User]) (*factory.Factory[User], error)
- func NewUserResource(dbRepository *repository.Repository[User]) (*api.Resource[User, CreateUserInput, UpdateUserInput, UserResponse], error)
- func NewUserResourceWithJobs(dbRepository *repository.Repository[User], jobClient *jobs.Client) (*api.Resource[User, CreateUserInput, UpdateUserInput, UserResponse], error)
- func RegisterJobs(jobClient *jobs.Client, users *repository.Repository[User], ...) error
- func Seed(ctx context.Context, users *repository.Repository[User]) error
- func SeedApplication(ctx context.Context, db *database.DB) error
- type Account
- type AccountResponse
- type CreateAccountInput
- type CreateProjectInput
- type CreateUserInput
- type Project
- type ProjectResponse
- type SendWelcomeEmail
- type UpdateAccountInput
- type UpdateProjectInput
- type UpdateUserInput
- type User
- type UserResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var Migrations = []migrate.Migration{ { Name: "001_create_accounts", Up: []string{ `CREATE TABLE accounts ( id UUID PRIMARY KEY, name VARCHAR(255) NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', metadata JSONB NOT NULL DEFAULT '{}'::jsonb, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), deleted_at TIMESTAMPTZ NULL, created_by UUID NULL, updated_by UUID NULL, deleted_by UUID NULL, slug VARCHAR(255) NOT NULL )`, `CREATE UNIQUE INDEX accounts_slug_unique ON accounts (slug) WHERE deleted_at IS NULL`, }, Down: []string{`DROP TABLE accounts`}, }, { Name: "002_create_users", Up: []string{ `CREATE TABLE users ( id UUID PRIMARY KEY, name VARCHAR(255) NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', metadata JSONB NOT NULL DEFAULT '{}'::jsonb, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), deleted_at TIMESTAMPTZ NULL, created_by UUID NULL, updated_by UUID NULL, deleted_by UUID NULL, email VARCHAR(255) NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, account_id UUID NULL REFERENCES accounts(id) )`, `CREATE UNIQUE INDEX users_email_unique ON users (email) WHERE deleted_at IS NULL`, }, Down: []string{`DROP TABLE users`}, }, { Name: "003_create_projects", Up: []string{ `CREATE TABLE projects ( id UUID PRIMARY KEY, name VARCHAR(255) NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', metadata JSONB NOT NULL DEFAULT '{}'::jsonb, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), deleted_at TIMESTAMPTZ NULL, created_by UUID NULL, updated_by UUID NULL, deleted_by UUID NULL, account_id UUID NOT NULL REFERENCES accounts(id), owner_id UUID NULL REFERENCES users(id), status VARCHAR(64) NOT NULL )`, `CREATE INDEX projects_account_id_idx ON projects (account_id)`, `CREATE INDEX projects_owner_id_idx ON projects (owner_id)`, `CREATE INDEX projects_status_idx ON projects (status)`, }, Down: []string{`DROP TABLE projects`}, }, }
Functions ¶
func NewAccountFactory ¶
func NewAccountFactory(accounts *repository.Repository[Account]) (*factory.Factory[Account], error)
func NewAccountResource ¶
func NewAccountResource(accounts *repository.Repository[Account]) (*api.Resource[Account, CreateAccountInput, UpdateAccountInput, AccountResponse], error)
func NewProjectFactory ¶
func NewProjectResource ¶
func NewProjectResource(projects *repository.Repository[Project]) (*api.Resource[Project, CreateProjectInput, UpdateProjectInput, ProjectResponse], error)
func NewUserFactory ¶
func NewUserFactory(users *repository.Repository[User]) (*factory.Factory[User], error)
func NewUserResource ¶
func NewUserResource(dbRepository *repository.Repository[User]) (*api.Resource[User, CreateUserInput, UpdateUserInput, UserResponse], error)
func NewUserResourceWithJobs ¶
func NewUserResourceWithJobs(dbRepository *repository.Repository[User], jobClient *jobs.Client) (*api.Resource[User, CreateUserInput, UpdateUserInput, UserResponse], error)
func RegisterJobs ¶
func RegisterJobs(jobClient *jobs.Client, users *repository.Repository[User], mailer *mail.Client) error
func Seed ¶
func Seed(ctx context.Context, users *repository.Repository[User]) error
Seed inserts one predictable development user and is safe to run repeatedly.
Types ¶
type Account ¶
type AccountResponse ¶
type CreateAccountInput ¶
type CreateProjectInput ¶
type CreateProjectInput struct {
Name string `json:"name" minLength:"1" maxLength:"255"`
Description string `json:"description,omitempty"`
Metadata model.Metadata `json:"metadata,omitempty"`
AccountID uuid.UUID `json:"account_id"`
OwnerID *uuid.UUID `json:"owner_id,omitempty"`
Status string `json:"status" minLength:"1" maxLength:"64"`
}
type CreateUserInput ¶
type ProjectResponse ¶
type ProjectResponse struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Metadata model.Metadata `json:"metadata"`
AccountID uuid.UUID `json:"account_id"`
OwnerID *uuid.UUID `json:"owner_id,omitempty"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type SendWelcomeEmail ¶
func (SendWelcomeEmail) Kind ¶
func (SendWelcomeEmail) Kind() string
type UpdateAccountInput ¶
type UpdateProjectInput ¶
type UpdateProjectInput struct {
Name *string `json:"name,omitempty" minLength:"1" maxLength:"255"`
Description *string `json:"description,omitempty"`
Metadata *model.Metadata `json:"metadata,omitempty"`
OwnerID **uuid.UUID `json:"owner_id,omitempty"`
Status *string `json:"status,omitempty" minLength:"1" maxLength:"64"`
}
type UpdateUserInput ¶
type User ¶
type User struct {
model.Base
Email string `bun:"email,notnull" json:"email" validate:"required,email"`
Active bool `bun:"active,notnull,default:true" json:"active"`
AccountID *uuid.UUID `bun:"account_id,nullzero" json:"account_id,omitempty"`
EmailChanged bool `bun:"-" json:"-"`
}
func (*User) AfterUpdate ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.