session

package
v0.0.0-...-b7dcdf6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableName = "session"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data map[string]interface{}

type IRepository

type IRepository interface {
	NewEntity(ctx context.Context, userId uint) (*Session, error)
	// Get returns the session with the specified user ID.
	GetByUserID(ctx context.Context, userId uint) (*Session, error)
	// Create saves a new entity in the storage.
	Create(ctx context.Context, entity *Session) error
	// Update updates the entity with given ID in the storage.
	Update(ctx context.Context, entity *Session) error
	// Delete removes the entity with given ID from the storage.
	Delete(ctx context.Context, id uint) error
	SetDefaultConditions(conditions map[string]interface{})
	GetVar(session *Session, name string) (interface{}, bool)
	SetVar(session *Session, name string, val interface{}) error
}

IRepository encapsulates the logic to access session from the data source.

type Session

type Session struct {
	ID     uint            `gorm:"PRIMARY_KEY" json:"id"`
	UserID uint            `sql:"type:int REFERENCES \"user\"(id)" json:"userId"`
	User   user.User       `gorm:"FOREIGNKEY:UserID;association_autoupdate:false" json:"author"`
	Json   string          `sql:"type:JSONB NOT NULL DEFAULT '{}'::JSONB"`
	Data   Data            `gorm:"-"`
	Ctx    context.Context `gorm:"-"`

	CreatedAt time.Time  `json:"created"`
	UpdatedAt time.Time  `json:"updated"`
	DeletedAt *time.Time `gorm:"INDEX" json:"deleted"`
}

Session is the session entity

func New

func New() *Session

New func is a constructor for the Post

func (*Session) SetDataByJson

func (s *Session) SetDataByJson() error

func (*Session) SetJsonByData

func (s *Session) SetJsonByData() error

func (Session) TableName

func (s Session) TableName() string

Jump to

Keyboard shortcuts

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