models

package
v0.0.0-...-569cda3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProposalFilterByUser

func ProposalFilterByUser(userID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

ProposalFilterByUser is a gorm filter for a Belongs To relationship.

func ReviewFilterByProposal

func ReviewFilterByProposal(proposalID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

ReviewFilterByProposal is a gorm filter for a Belongs To relationship.

func ReviewFilterByUser

func ReviewFilterByUser(userID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

ReviewFilterByUser is a gorm filter for a Belongs To relationship.

Types

type Proposal

type Proposal struct {
	ID        int `gorm:"primary_key"` // This is the Payload Model PK field
	Abstract  string
	Detail    string
	Reviews   []Review // has many Reviews
	Title     string
	UserID    int // has many Proposal
	Withdrawn *bool
	CreatedAt time.Time  // timestamp
	DeletedAt *time.Time // nullable timestamp (soft delete)
	UpdatedAt time.Time  // timestamp
	User      User
}

Proposal Model

func ProposalFromCreateProposalPayload

func ProposalFromCreateProposalPayload(payload *app.CreateProposalPayload) *Proposal

ProposalFromCreateProposalPayload Converts source CreateProposalPayload to target Proposal model only copying the non-nil fields from the source.

func ProposalFromUpdateProposalPayload

func ProposalFromUpdateProposalPayload(payload *app.UpdateProposalPayload) *Proposal

ProposalFromUpdateProposalPayload Converts source UpdateProposalPayload to target Proposal model only copying the non-nil fields from the source.

func (*Proposal) ProposalToProposal

func (m *Proposal) ProposalToProposal() *app.Proposal

ProposalToProposal loads a Proposal and builds the default view of media type Proposal.

func (m *Proposal) ProposalToProposalLink() *app.ProposalLink

ProposalToProposalLink loads a Proposal and builds the link view of media type Proposal.

func (Proposal) TableName

func (m Proposal) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type ProposalDB

type ProposalDB struct {
	Db gorm.DB
}

ProposalDB is the implementation of the storage interface for Proposal.

func NewProposalDB

func NewProposalDB(db gorm.DB) *ProposalDB

NewProposalDB creates a new storage type.

func (*ProposalDB) Add

func (m *ProposalDB) Add(ctx context.Context, model *Proposal) (*Proposal, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*ProposalDB) DB

func (m *ProposalDB) DB() interface{}

DB returns the underlying database.

func (*ProposalDB) Delete

func (m *ProposalDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*ProposalDB) Get

func (m *ProposalDB) Get(ctx context.Context, id int) (Proposal, error)

Get returns a single Proposal as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*ProposalDB) List

func (m *ProposalDB) List(ctx context.Context) []Proposal

List returns an array of Proposal

func (*ProposalDB) ListProposal

func (m *ProposalDB) ListProposal(ctx context.Context, userID int) []*app.Proposal

ListProposal returns an array of view: default.

func (m *ProposalDB) ListProposalLink(ctx context.Context, userID int) []*app.ProposalLink

ListProposalLink returns an array of view: link.

func (*ProposalDB) OneProposal

func (m *ProposalDB) OneProposal(ctx context.Context, id int, userID int) (*app.Proposal, error)

OneProposal loads a Proposal and builds the default view of media type Proposal.

func (m *ProposalDB) OneProposalLink(ctx context.Context, id int, userID int) (*app.ProposalLink, error)

OneProposalLink loads a Proposal and builds the link view of media type Proposal.

func (*ProposalDB) TableName

func (m *ProposalDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*ProposalDB) Update

func (m *ProposalDB) Update(ctx context.Context, model *Proposal) error

Update modifies a single record.

func (*ProposalDB) UpdateFromCreateProposalPayload

func (m *ProposalDB) UpdateFromCreateProposalPayload(ctx context.Context, payload *app.CreateProposalPayload, id int) error

UpdateFromCreateProposalPayload applies non-nil changes from CreateProposalPayload to the model and saves it

func (*ProposalDB) UpdateFromUpdateProposalPayload

func (m *ProposalDB) UpdateFromUpdateProposalPayload(ctx context.Context, payload *app.UpdateProposalPayload, id int) error

UpdateFromUpdateProposalPayload applies non-nil changes from UpdateProposalPayload to the model and saves it

type ProposalStorage

type ProposalStorage interface {
	DB() interface{}
	List(ctx context.Context) []Proposal
	Get(ctx context.Context, id int) (Proposal, error)
	Add(ctx context.Context, proposal *Proposal) (*Proposal, error)
	Update(ctx context.Context, proposal *Proposal) error
	Delete(ctx context.Context, id int) error

	ListProposal(ctx context.Context, userID int) []*app.Proposal
	OneProposal(ctx context.Context, id int, userID int) (*app.Proposal, error)

	ListProposalLink(ctx context.Context, userID int) []*app.ProposalLink
	OneProposalLink(ctx context.Context, id int, userID int) (*app.ProposalLink, error)

	UpdateFromCreateProposalPayload(ctx context.Context, payload *app.CreateProposalPayload, id int) error

	UpdateFromUpdateProposalPayload(ctx context.Context, payload *app.UpdateProposalPayload, id int) error
}

ProposalStorage represents the storage interface.

type Review

type Review struct {
	ID         int `gorm:"primary_key"` // This is the Review Model PK field
	Comment    *string
	ProposalID int // Belongs To Proposal
	Rating     int
	UserID     int        // has many Review
	CreatedAt  time.Time  // timestamp
	DeletedAt  *time.Time // nullable timestamp (soft delete)
	UpdatedAt  time.Time  // timestamp
	Proposal   Proposal
	User       User
}

Review Model

func ReviewFromCreateReviewPayload

func ReviewFromCreateReviewPayload(payload *app.CreateReviewPayload) *Review

ReviewFromCreateReviewPayload Converts source CreateReviewPayload to target Review model only copying the non-nil fields from the source.

func ReviewFromUpdateReviewPayload

func ReviewFromUpdateReviewPayload(payload *app.UpdateReviewPayload) *Review

ReviewFromUpdateReviewPayload Converts source UpdateReviewPayload to target Review model only copying the non-nil fields from the source.

func (*Review) ReviewToReview

func (m *Review) ReviewToReview() *app.Review

ReviewToReview loads a Review and builds the default view of media type Review.

func (m *Review) ReviewToReviewLink() *app.ReviewLink

ReviewToReviewLink loads a Review and builds the link view of media type Review.

func (Review) TableName

func (m Review) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type ReviewDB

type ReviewDB struct {
	Db gorm.DB
}

ReviewDB is the implementation of the storage interface for Review.

func NewReviewDB

func NewReviewDB(db gorm.DB) *ReviewDB

NewReviewDB creates a new storage type.

func (*ReviewDB) Add

func (m *ReviewDB) Add(ctx context.Context, model *Review) (*Review, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*ReviewDB) DB

func (m *ReviewDB) DB() interface{}

DB returns the underlying database.

func (*ReviewDB) Delete

func (m *ReviewDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*ReviewDB) Get

func (m *ReviewDB) Get(ctx context.Context, id int) (Review, error)

Get returns a single Review as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*ReviewDB) List

func (m *ReviewDB) List(ctx context.Context) []Review

List returns an array of Review

func (*ReviewDB) ListReview

func (m *ReviewDB) ListReview(ctx context.Context, proposalID int, userID int) []*app.Review

ListReview returns an array of view: default.

func (m *ReviewDB) ListReviewLink(ctx context.Context, proposalID int, userID int) []*app.ReviewLink

ListReviewLink returns an array of view: link.

func (*ReviewDB) OneReview

func (m *ReviewDB) OneReview(ctx context.Context, id int, proposalID int, userID int) (*app.Review, error)

OneReview loads a Review and builds the default view of media type Review.

func (m *ReviewDB) OneReviewLink(ctx context.Context, id int, proposalID int, userID int) (*app.ReviewLink, error)

OneReviewLink loads a Review and builds the link view of media type Review.

func (*ReviewDB) TableName

func (m *ReviewDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*ReviewDB) Update

func (m *ReviewDB) Update(ctx context.Context, model *Review) error

Update modifies a single record.

func (*ReviewDB) UpdateFromCreateReviewPayload

func (m *ReviewDB) UpdateFromCreateReviewPayload(ctx context.Context, payload *app.CreateReviewPayload, id int) error

UpdateFromCreateReviewPayload applies non-nil changes from CreateReviewPayload to the model and saves it

func (*ReviewDB) UpdateFromUpdateReviewPayload

func (m *ReviewDB) UpdateFromUpdateReviewPayload(ctx context.Context, payload *app.UpdateReviewPayload, id int) error

UpdateFromUpdateReviewPayload applies non-nil changes from UpdateReviewPayload to the model and saves it

type ReviewStorage

type ReviewStorage interface {
	DB() interface{}
	List(ctx context.Context) []Review
	Get(ctx context.Context, id int) (Review, error)
	Add(ctx context.Context, review *Review) (*Review, error)
	Update(ctx context.Context, review *Review) error
	Delete(ctx context.Context, id int) error

	ListReview(ctx context.Context, proposalID int, userID int) []*app.Review
	OneReview(ctx context.Context, id int, proposalID int, userID int) (*app.Review, error)

	ListReviewLink(ctx context.Context, proposalID int, userID int) []*app.ReviewLink
	OneReviewLink(ctx context.Context, id int, proposalID int, userID int) (*app.ReviewLink, error)

	UpdateFromCreateReviewPayload(ctx context.Context, payload *app.CreateReviewPayload, id int) error

	UpdateFromUpdateReviewPayload(ctx context.Context, payload *app.UpdateReviewPayload, id int) error
}

ReviewStorage represents the storage interface.

type Test

type Test struct {
	CreatedAt time.Time  // timestamp
	DeletedAt *time.Time // nullable timestamp (soft delete)
	UpdatedAt time.Time  // timestamp
}

Test Model

func (Test) TableName

func (m Test) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type TestDB

type TestDB struct {
	Db gorm.DB
}

TestDB is the implementation of the storage interface for Test.

func NewTestDB

func NewTestDB(db gorm.DB) *TestDB

NewTestDB creates a new storage type.

func (*TestDB) Add

func (m *TestDB) Add(ctx context.Context, model *Test) (*Test, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*TestDB) DB

func (m *TestDB) DB() interface{}

DB returns the underlying database.

func (*TestDB) Delete

func (m *TestDB) Delete(ctx context.Context) error

Delete removes a single record.

func (*TestDB) Get

func (m *TestDB) Get(ctx context.Context) (Test, error)

Get returns a single Test as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*TestDB) List

func (m *TestDB) List(ctx context.Context) []Test

List returns an array of Test

func (*TestDB) TableName

func (m *TestDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*TestDB) Update

func (m *TestDB) Update(ctx context.Context, model *Test) error

Update modifies a single record.

type TestStorage

type TestStorage interface {
	DB() interface{}
	List(ctx context.Context) []Test
	Get(ctx context.Context) (Test, error)
	Add(ctx context.Context, test *Test) (*Test, error)
	Update(ctx context.Context, test *Test) error
	Delete(ctx context.Context) error
}

TestStorage represents the storage interface.

type TestToo

type TestToo struct {
	Idone     int `gorm:"primary_key"` // This is one of the TestToo Model PK fields
	Idtwo     int `gorm:"primary_key"` // This is one of the TestToo Model PK fields
	Bio       *string
	City      *string
	Country   *string
	Email     string
	Firstname string
	Lastname  string
	State     *string
	CreatedAt time.Time  // timestamp
	DeletedAt *time.Time // nullable timestamp (soft delete)
	UpdatedAt time.Time  // timestamp
}

TestToo Model

func TestTooFromCreateUserPayload

func TestTooFromCreateUserPayload(payload *app.CreateUserPayload) *TestToo

TestTooFromCreateUserPayload Converts source CreateUserPayload to target TestToo model only copying the non-nil fields from the source.

func TestTooFromUpdateUserPayload

func TestTooFromUpdateUserPayload(payload *app.UpdateUserPayload) *TestToo

TestTooFromUpdateUserPayload Converts source UpdateUserPayload to target TestToo model only copying the non-nil fields from the source.

func (TestToo) TableName

func (m TestToo) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*TestToo) TestTooToUser

func (m *TestToo) TestTooToUser() *app.User

TestTooToUser loads a TestToo and builds the default view of media type User.

func (m *TestToo) TestTooToUserLink() *app.UserLink

TestTooToUserLink loads a TestToo and builds the link view of media type User.

type TestTooDB

type TestTooDB struct {
	Db gorm.DB
}

TestTooDB is the implementation of the storage interface for TestToo.

func NewTestTooDB

func NewTestTooDB(db gorm.DB) *TestTooDB

NewTestTooDB creates a new storage type.

func (*TestTooDB) Add

func (m *TestTooDB) Add(ctx context.Context, model *TestToo) (*TestToo, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*TestTooDB) DB

func (m *TestTooDB) DB() interface{}

DB returns the underlying database.

func (*TestTooDB) Delete

func (m *TestTooDB) Delete(ctx context.Context, idone int, idtwo int) error

Delete removes a single record.

func (*TestTooDB) Get

func (m *TestTooDB) Get(ctx context.Context, idone int, idtwo int) (TestToo, error)

Get returns a single TestToo as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*TestTooDB) List

func (m *TestTooDB) List(ctx context.Context) []TestToo

List returns an array of TestToo

func (*TestTooDB) ListUser

func (m *TestTooDB) ListUser(ctx context.Context) []*app.User

ListUser returns an array of view: default.

func (m *TestTooDB) ListUserLink(ctx context.Context) []*app.UserLink

ListUserLink returns an array of view: link.

func (*TestTooDB) OneUser

func (m *TestTooDB) OneUser(ctx context.Context, idone int, idtwo int) (*app.User, error)

OneUser loads a TestToo and builds the default view of media type User.

func (m *TestTooDB) OneUserLink(ctx context.Context, idone int, idtwo int) (*app.UserLink, error)

OneUserLink loads a TestToo and builds the link view of media type User.

func (*TestTooDB) TableName

func (m *TestTooDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*TestTooDB) Update

func (m *TestTooDB) Update(ctx context.Context, model *TestToo) error

Update modifies a single record.

func (*TestTooDB) UpdateFromCreateUserPayload

func (m *TestTooDB) UpdateFromCreateUserPayload(ctx context.Context, payload *app.CreateUserPayload, idone int, idtwo int) error

UpdateFromCreateUserPayload applies non-nil changes from CreateUserPayload to the model and saves it

func (*TestTooDB) UpdateFromUpdateUserPayload

func (m *TestTooDB) UpdateFromUpdateUserPayload(ctx context.Context, payload *app.UpdateUserPayload, idone int, idtwo int) error

UpdateFromUpdateUserPayload applies non-nil changes from UpdateUserPayload to the model and saves it

type TestTooStorage

type TestTooStorage interface {
	DB() interface{}
	List(ctx context.Context) []TestToo
	Get(ctx context.Context, idone int, idtwo int) (TestToo, error)
	Add(ctx context.Context, testtoo *TestToo) (*TestToo, error)
	Update(ctx context.Context, testtoo *TestToo) error
	Delete(ctx context.Context, idone int, idtwo int) error

	ListUser(ctx context.Context) []*app.User
	OneUser(ctx context.Context, idone int, idtwo int) (*app.User, error)

	ListUserLink(ctx context.Context) []*app.UserLink
	OneUserLink(ctx context.Context, idone int, idtwo int) (*app.UserLink, error)

	UpdateFromCreateUserPayload(ctx context.Context, payload *app.CreateUserPayload, idone int, idtwo int) error

	UpdateFromUpdateUserPayload(ctx context.Context, payload *app.UpdateUserPayload, idone int, idtwo int) error
}

TestTooStorage represents the storage interface.

type User

type User struct {
	ID        int `gorm:"primary_key"` // This is the User Model PK field
	Bio       *string
	City      *string
	Country   *string
	Email     string
	Firstname string
	Lastname  string
	Proposals []Proposal // has many Proposals
	Reviews   []Review   // has many Reviews
	State     *string
	CreatedAt time.Time  // timestamp
	DeletedAt *time.Time // nullable timestamp (soft delete)
	UpdatedAt time.Time  // timestamp
}

User Model Description

func UserFromCreateUserPayload

func UserFromCreateUserPayload(payload *app.CreateUserPayload) *User

UserFromCreateUserPayload Converts source CreateUserPayload to target User model only copying the non-nil fields from the source.

func UserFromUpdateUserPayload

func UserFromUpdateUserPayload(payload *app.UpdateUserPayload) *User

UserFromUpdateUserPayload Converts source UpdateUserPayload to target User model only copying the non-nil fields from the source.

func (User) TableName

func (m User) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*User) UserToUser

func (m *User) UserToUser() *app.User

UserToUser loads a User and builds the default view of media type User.

func (m *User) UserToUserLink() *app.UserLink

UserToUserLink loads a User and builds the link view of media type User.

type UserDB

type UserDB struct {
	Db gorm.DB
}

UserDB is the implementation of the storage interface for User.

func NewUserDB

func NewUserDB(db gorm.DB) *UserDB

NewUserDB creates a new storage type.

func (*UserDB) Add

func (m *UserDB) Add(ctx context.Context, model *User) (*User, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*UserDB) DB

func (m *UserDB) DB() interface{}

DB returns the underlying database.

func (*UserDB) Delete

func (m *UserDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*UserDB) Get

func (m *UserDB) Get(ctx context.Context, id int) (User, error)

Get returns a single User as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*UserDB) List

func (m *UserDB) List(ctx context.Context) []User

List returns an array of User

func (*UserDB) ListUser

func (m *UserDB) ListUser(ctx context.Context) []*app.User

ListUser returns an array of view: default.

func (m *UserDB) ListUserLink(ctx context.Context) []*app.UserLink

ListUserLink returns an array of view: link.

func (*UserDB) OneUser

func (m *UserDB) OneUser(ctx context.Context, id int) (*app.User, error)

OneUser loads a User and builds the default view of media type User.

func (m *UserDB) OneUserLink(ctx context.Context, id int) (*app.UserLink, error)

OneUserLink loads a User and builds the link view of media type User.

func (*UserDB) TableName

func (m *UserDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*UserDB) Update

func (m *UserDB) Update(ctx context.Context, model *User) error

Update modifies a single record.

func (*UserDB) UpdateFromCreateUserPayload

func (m *UserDB) UpdateFromCreateUserPayload(ctx context.Context, payload *app.CreateUserPayload, id int) error

UpdateFromCreateUserPayload applies non-nil changes from CreateUserPayload to the model and saves it

func (*UserDB) UpdateFromUpdateUserPayload

func (m *UserDB) UpdateFromUpdateUserPayload(ctx context.Context, payload *app.UpdateUserPayload, id int) error

UpdateFromUpdateUserPayload applies non-nil changes from UpdateUserPayload to the model and saves it

type UserStorage

type UserStorage interface {
	DB() interface{}
	List(ctx context.Context) []User
	Get(ctx context.Context, id int) (User, error)
	Add(ctx context.Context, user *User) (*User, error)
	Update(ctx context.Context, user *User) error
	Delete(ctx context.Context, id int) error

	ListUser(ctx context.Context) []*app.User
	OneUser(ctx context.Context, id int) (*app.User, error)

	ListUserLink(ctx context.Context) []*app.UserLink
	OneUserLink(ctx context.Context, id int) (*app.UserLink, error)

	UpdateFromCreateUserPayload(ctx context.Context, payload *app.CreateUserPayload, id int) error

	UpdateFromUpdateUserPayload(ctx context.Context, payload *app.UpdateUserPayload, id int) error
}

UserStorage represents the storage interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL