Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
type Account struct { // Some notes on GORM conventions: // 1. struct name Account corresponds to table name accounts. PetOwner corresponds to pet_owners // 2. struct field ID corresponds to table column id and is understood to be the primary key // 3. struct fields are CamelCase and table columns are snake_case. CreatedAt == created_at // 4. TeamID is understood to refer to struct field Team.ID, or table column teams.id and is a foreign key. ID int Name string Email string CreatedAt time.Time UpdatedAt time.Time TeamID *int // related data is held in this embedded struct Team Team }
Maintain an Account model just for use with the DB to prevent coupling between the service layer and the storage layer. storage.Account (the DB table model) can be converted to an api.Account (the business object) using its toEntity method.
type AccountRepository ¶
type AccountRepository struct {
// contains filtered or unexported fields
}
storage.AccountRepository represents a MySQL implementation of api.AccountRepository.
func NewAccountRepository ¶
func NewAccountRepository(db *gorm.DB) AccountRepository
func (*AccountRepository) CreateAccount ¶
func (s *AccountRepository) CreateAccount(a *api.Account) error
func (*AccountRepository) DeleteAccount ¶
func (s *AccountRepository) DeleteAccount(id int) error
func (*AccountRepository) GetAccount ¶
func (s *AccountRepository) GetAccount(id int) (*api.Account, error)
func (*AccountRepository) ListAccounts ¶
func (s *AccountRepository) ListAccounts() ([]*api.Account, error)
Click to show internal directories.
Click to hide internal directories.