models

package
v0.0.0-...-140d0cf Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	ID        int `gorm:"primary_key"` // primary key
	CreatedAt time.Time
	DeletedAt *time.Time
	Message   string
	UpdatedAt time.Time
}

Message model

func (*Message) MessageToMessagetype

func (m *Message) MessageToMessagetype() *app.Messagetype

MessageToMessagetype loads a Message and builds the default view of media type Messagetype.

func (Message) TableName

func (m Message) TableName() string

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

type MessageDB

type MessageDB struct {
	Db *gorm.DB
}

MessageDB is the implementation of the storage interface for Message.

func NewMessageDB

func NewMessageDB(db *gorm.DB) *MessageDB

NewMessageDB creates a new storage type.

func (*MessageDB) Add

func (m *MessageDB) Add(ctx context.Context, model *Message) error

Add creates a new record.

func (*MessageDB) DB

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

DB returns the underlying database.

func (*MessageDB) Delete

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

Delete removes a single record.

func (*MessageDB) Get

func (m *MessageDB) Get(ctx context.Context, id int) (*Message, error)

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

func (*MessageDB) List

func (m *MessageDB) List(ctx context.Context) ([]*Message, error)

List returns an array of Message

func (*MessageDB) ListMessagetype

func (m *MessageDB) ListMessagetype(ctx context.Context) []*app.Messagetype

ListMessagetype returns an array of view: default.

func (*MessageDB) OneMessagetype

func (m *MessageDB) OneMessagetype(ctx context.Context, id int) (*app.Messagetype, error)

OneMessagetype loads a Message and builds the default view of media type Messagetype.

func (*MessageDB) TableName

func (m *MessageDB) TableName() string

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

func (*MessageDB) Update

func (m *MessageDB) Update(ctx context.Context, model *Message) error

Update modifies a single record.

type MessageStorage

type MessageStorage interface {
	DB() interface{}
	List(ctx context.Context) ([]*Message, error)
	Get(ctx context.Context, id int) (*Message, error)
	Add(ctx context.Context, message *Message) error
	Update(ctx context.Context, message *Message) error
	Delete(ctx context.Context, id int) error

	ListMessagetype(ctx context.Context) []*app.Messagetype
	OneMessagetype(ctx context.Context, id int) (*app.Messagetype, error)
}

MessageStorage represents the storage interface.

Jump to

Keyboard shortcuts

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