model

package
v0.0.0-...-88cf978 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB connecter

Functions

func Migration

func Migration()

Migration does database migrations

func SetupDB

func SetupDB()

SetupDB is database setuo

Types

type Application

type Application struct {
	Base
	Name           string             `gorm:"column:name" json:"name"`
	Slug           string             `gorm:"column:slug" json:"slug"`
	Description    string             `gorm:"column:description" json:"description"`
	URL            string             `gorm:"column:url" json:"url"`
	MediumID       *uint              `gorm:"column:medium_id;default:NULL" json:"medium_id"`
	Medium         *Medium            `gorm:"foreignKey:medium_id" json:"medium"`
	OrganisationID uint               `gorm:"column:organisation_id" json:"organisation_id"`
	Organisation   *Organisation      `gorm:"foreignKey:organisation_id" json:"organisation,omitempty"`
	Users          []User             `gorm:"many2many:application_users;" json:"users"`
	Tokens         []ApplicationToken `json:"tokens"`
}

Application model defination

func (*Application) BeforeCreate

func (application *Application) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

func (*Application) BeforeSave

func (application *Application) BeforeSave(tx *gorm.DB) (e error)

BeforeSave - validation for medium

type ApplicationToken

type ApplicationToken struct {
	Base
	Name          string       `gorm:"column:name" json:"name"`
	Description   string       `gorm:"column:description" json:"description"`
	ApplicationID *uint        `gorm:"column:application_id" json:"application_id"`
	Application   *Application `gorm:"foreignKey:application_id" json:"application"`
	AccessToken   string       `gorm:"column:access_token" json:"access_token,omitempty"`
	HashedToken   string       `gorm:"column:hashed_token" json:"-"`
}

type Base

type Base struct {
	ID          uint            `gorm:"primaryKey" json:"id"`
	CreatedAt   time.Time       `json:"created_at"`
	UpdatedAt   time.Time       `json:"updated_at"`
	DeletedAt   *gorm.DeletedAt `gorm:"index" json:"deleted_at" swaggertype:"primitive,string"`
	CreatedByID uint            `gorm:"column:created_by_id" json:"created_by_id"`
	UpdatedByID uint            `gorm:"column:updated_by_id" json:"updated_by_id"`
}

Base with id, created_at, updated_at & deleted_at

type ContextKey

type ContextKey string

ContextKey string type

type Medium

type Medium struct {
	Base
	Name        string         `gorm:"column:name" json:"name"`
	Slug        string         `gorm:"column:slug" json:"slug"`
	Type        string         `gorm:"column:type" json:"type"`
	Title       string         `gorm:"column:title" json:"title"`
	Description string         `gorm:"column:description" json:"description"`
	Caption     string         `gorm:"column:caption" json:"caption"`
	AltText     string         `gorm:"column:alt_text" json:"alt_text"`
	FileSize    int64          `gorm:"column:file_size" json:"file_size"`
	URL         postgres.Jsonb `gorm:"column:url" json:"url" swaggertype:"primitive,string"`
	Dimensions  string         `gorm:"column:dimensions" json:"dimensions"`
	UserID      uint           `gorm:"column:user_id" json:"user_id"`
}

Medium model

func (*Medium) AfterCreate

func (media *Medium) AfterCreate(tx *gorm.DB) (err error)

AfterCreate hook

func (*Medium) AfterFind

func (media *Medium) AfterFind(tx *gorm.DB) (err error)

AfterFind hook

func (*Medium) BeforeCreate

func (media *Medium) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

func (Medium) TableName

func (Medium) TableName() string

TableName medium table name

type Organisation

type Organisation struct {
	Base
	Title            string  `gorm:"column:title" json:"title"`
	Slug             string  `gorm:"column:slug" json:"slug"`
	Description      string  `gorm:"column:description" json:"description"`
	FeaturedMediumID *uint   `gorm:"column:featured_medium_id;default:NULL" json:"featured_medium_id"`
	Medium           *Medium `gorm:"foreignKey:featured_medium_id" json:"medium"`
}

Organisation model definition

func (*Organisation) BeforeCreate

func (org *Organisation) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

func (*Organisation) BeforeSave

func (org *Organisation) BeforeSave(tx *gorm.DB) (e error)

BeforeSave - validation for medium

type OrganisationUser

type OrganisationUser struct {
	Base
	UserID         uint          `gorm:"column:user_id" json:"user_id"`
	User           *User         `json:"user"`
	OrganisationID uint          `gorm:"column:organisation_id" json:"organisation_id"`
	Organisation   *Organisation `json:"organisation"`
	Role           string        `gorm:"column:role" json:"role"`
}

OrganisationUser model definition

func (*OrganisationUser) BeforeCreate

func (orgUser *OrganisationUser) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type Policy

type Policy struct {
	ID        string   `json:"id"`
	Subjects  []string `json:"subjects"`
	Resources []string `json:"resources"`
	Actions   []string `json:"actions"`
	Effect    string   `json:"effect"`
}

Policy in keto

type Role

type Role struct {
	ID      string   `json:"id"`
	Members []string `json:"members"`
}

Role in keto

type User

type User struct {
	Base
	Email            string         `gorm:"column:email;uniqueIndex" json:"email"`
	KID              string         `gorm:"column:kid;" json:"kid"`
	FirstName        string         `gorm:"column:first_name" json:"first_name"`
	LastName         string         `gorm:"column:last_name" json:"last_name"`
	Slug             string         `gorm:"column:slug" json:"slug"`
	DisplayName      string         `gorm:"column:display_name" json:"display_name"`
	BirthDate        string         `gorm:"column:birth_date" json:"birth_date"`
	Gender           string         `gorm:"column:gender" json:"gender"`
	FeaturedMediumID *uint          `gorm:"column:featured_medium_id;default:NULL" json:"featured_medium_id"`
	Medium           *Medium        `gorm:"foreignKey:featured_medium_id" json:"medium"`
	SocialMediaURLs  postgres.Jsonb `gorm:"column:social_media_urls" json:"social_media_urls" swaggertype:"primitive,string"`
	Description      string         `gorm:"column:description" json:"description"`
}

User model definition

func (*User) BeforeUpdate

func (user *User) BeforeUpdate(tx *gorm.DB) (e error)

BeforeUpdate - validation for medium

Jump to

Keyboard shortcuts

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