model

package
v0.0.0-...-643f1d8 Latest Latest
Warning

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

Go to latest
Published: May 29, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB - gorm DB

Functions

func Migration

func Migration()

Migration does database migrations

func SetupDB

func SetupDB()

SetupDB is database setup

Types

type Base

type Base struct {
	ID          uint            `gorm:"primary_key" json:"id"`
	CreatedAt   time.Time       `json:"created_at"`
	UpdatedAt   time.Time       `json:"updated_at"`
	DeletedAt   *gorm.DeletedAt `sql:"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 CartItem

type CartItem struct {
	Base
	Status       string      `gorm:"column:status" json:"status" validate:"required"`
	UserID       uint        `gorm:"column:user_id" json:"user_id" validate:"required"`
	ProductID    uint        `gorm:"column:product_id" json:"product_id" validate:"required"`
	Product      *Product    `gorm:"foreignKey:product_id" json:"product"`
	MembershipID *uint       `gorm:"column:membership_id;default:NULL" json:"membership_id"`
	Membership   *Membership `gorm:"foreignKey:membership_id" json:"membership"`
}

CartItem model

func (*CartItem) BeforeCreate

func (cartitem *CartItem) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type Catalog

type Catalog struct {
	Base
	Title            string     `gorm:"column:title" json:"title"`
	Slug             string     `gorm:"column:slug" json:"slug"`
	Price            int        `gorm:"column:price" json:"price"`
	CurrencyID       uint       `gorm:"column:currency_id" json:"currency_id"`
	Currency         Currency   `gorm:"foreignKey:currency_id"  json:"currency"`
	Description      string     `gorm:"column:description" json:"description"`
	FeaturedMediumID *uint      `gorm:"column:featured_medium_id;default:NULL" json:"featured_medium_id"`
	FeaturedMedium   *Medium    `gorm:"foreignKey:featured_medium_id"  json:"featured_medium"`
	PublishedDate    *time.Time `gorm:"column:published_date" json:"published_date" sql:"DEFAULT:NULL"`
	Plans            []Plan     `gorm:"many2many:plan_catalog;" json:"plans"`
	Products         []Product  `gorm:"many2many:catalog_product;" json:"products"`
}

Catalog model

func (*Catalog) BeforeCreate

func (catalog *Catalog) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type ContextKey

type ContextKey string

ContextKey keys for contexts

type Currency

type Currency struct {
	Base
	IsoCode string `gorm:"column:iso_code" json:"iso_code" validate:"required"`
	Name    string `gorm:"column:name" json:"name" validate:"required"`
}

Currency model

func (*Currency) BeforeCreate

func (currency *Currency) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type Dataset

type Dataset struct {
	Base
	Title            string         `gorm:"column:title" json:"title"`
	Description      string         `gorm:"column:description" json:"description"`
	Source           string         `gorm:"column:source" json:"source"`
	SourceLink       string         `gorm:"column:source_link" json:"source_link"`
	ArchiveLink      string         `gorm:"column:archive_link" json:"archive_link"`
	Sectors          string         `gorm:"column:sectors" json:"sectors"`
	Organisation     string         `gorm:"column:organisation" json:"organisation"`
	Units            string         `gorm:"column:units" json:"units"`
	NextUpdate       *time.Time     `gorm:"column:next_update" json:"next_update"  sql:"DEFAULT:NULL"`
	Frequency        string         `gorm:"column:frequency" json:"frequency"`
	TemporalCoverage string         `gorm:"column:temporal_coverage" json:"temporal_coverage"`
	Granularity      string         `gorm:"column:granularity" json:"granularity"`
	ContactName      string         `gorm:"column:contact_name" json:"contact_name"`
	ContactEmail     string         `gorm:"column:contact_email" json:"contact_email"`
	License          string         `gorm:"column:license" json:"license"`
	DataStandard     string         `gorm:"column:data_standard" json:"data_standard"`
	SampleURL        string         `gorm:"column:sample_url" json:"sample_url"`
	ProfilingURL     string         `gorm:"column:profiling_url" json:"profiling_url"`
	IsPublic         bool           `gorm:"column:is_public" json:"is_public"`
	RelatedArticles  postgres.Jsonb `gorm:"column:related_articles" json:"related_articles" swaggertype:"primitive,string"`
	TimeSaved        int            `gorm:"column:time_saved" json:"time_saved"`
	Price            int            `gorm:"column:price" json:"price" validate:"required"`
	CurrencyID       uint           `gorm:"column:currency_id" json:"currency_id" validate:"required"`
	Currency         *Currency      `gorm:"foreignkey:currency_id" json:"currency"`
	FeaturedMediumID *uint          `gorm:"column:featured_medium_id;default:NULL" json:"featured_medium_id"`
	FeaturedMedium   *Medium        `gorm:"foreignKey:featured_medium_id" json:"featured_medium"`
	Products         []Product      `gorm:"many2many:product_dataset;" json:"products"`
	Tags             []Tag          `gorm:"many2many:dataset_tag;" json:"tags"`
}

Dataset model

func (*Dataset) BeforeCreate

func (dataset *Dataset) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type DatasetFormat

type DatasetFormat struct {
	Base
	FormatID  uint   `gorm:"column:format_id" json:"format_id"`
	Format    Format `gorm:"foreignKey:format_id"  json:"format"`
	DatasetID uint   `gorm:"column:dataset_id" json:"dataset_id"`
	URL       string `gorm:"column:url" json:"url"`
}

DatasetFormat model

func (*DatasetFormat) BeforeCreate

func (df *DatasetFormat) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type FailedPaymentEvent

type FailedPaymentEvent struct {
	Entity    string         `json:"entity,omitempty"`
	AccountID string         `json:"account_id,omitempty"`
	Event     string         `json:"event,omitempty"`
	Contains  []string       `json:"contains,omitempty"`
	Payload   PaymentPayload `json:"payload,omitempty"`
	CreatedAt uint32         `json:"created_at,omitempty"`
}

FailedPaymentEvent razorpay object

type Format

type Format struct {
	Base
	Name        string `gorm:"column:name" json:"name"`
	Description string `gorm:"column:description" json:"description" `
	IsDefault   bool   `gorm:"column:is_default" json:"is_default" `
}

Format model

func (*Format) BeforeCreate

func (format *Format) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type KetoPolicy

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

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    int            `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"`
}

Medium model

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

type Member

type Member 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"`
}

Author model

type Membership

type Membership struct {
	Base
	Status          string   `gorm:"column:status" json:"status" validate:"required"`
	UserID          uint     `gorm:"column:user_id" json:"user_id" validate:"required"`
	OrganisationID  uint     `gorm:"column:organisation_id" json:"organisation_id" validate:"required"`
	PaymentID       *uint    `gorm:"column:payment_id" json:"payment_id" sql:"DEFAULT:NULL"`
	Payment         *Payment `gorm:"foreignKey:payment_id" json:"payment"`
	PlanID          uint     `gorm:"column:plan_id" json:"plan_id" validate:"required"`
	Plan            Plan     `gorm:"foreignKey:plan_id" json:"plan"`
	RazorpayOrderID string   `gorm:"column:razorpay_order_id" json:"razorpay_order_id" sql:"DEFAULT:NULL"`
}

Membership model

func (*Membership) BeforeCreate

func (membership *Membership) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type Order

type Order struct {
	Base
	UserID          uint      `gorm:"column:user_id" json:"user_id" validate:"required"`
	Status          string    `gorm:"column:status" json:"status" validate:"required"`
	PaymentID       *uint     `gorm:"column:payment_id" json:"payment_id" sql:"DEFAULT:NULL"`
	Payment         *Payment  `gorm:"foreignKey:payment_id" json:"payment"`
	RazorpayOrderID string    `gorm:"column:razorpay_order_id" json:"razorpay_order_id" sql:"DEFAULT:NULL"`
	Products        []Product `gorm:"many2many:order_item;" json:"products"`
}

Order model

func (*Order) BeforeCreate

func (order *Order) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type OrgWithRole

type OrgWithRole struct {
	Organisation
	Permission OrganisationUser `json:"permission"`
}

OrgWithRole model definition

type Organisation

type Organisation struct {
	Base
	Title            string  `json:"title"`
	Slug             string  `json:"slug"`
	Description      string  `json:"description"`
	FeaturedMediumID *uint   `json:"featured_medium_id"`
	Medium           *Medium `json:"medium"`
}

Organisation model definition

type OrganisationUser

type OrganisationUser struct {
	Base
	UserID         uint   `json:"user_id"`
	OrganisationID uint   `json:"organisation_id"`
	Role           string `json:"role"`
}

OrganisationUser model definition

type Payment

type Payment struct {
	Base
	Amount            int      `gorm:"column:amount" json:"amount" validate:"required"`
	Gateway           string   `gorm:"column:gateway" json:"gateway" validate:"required"`
	CurrencyID        uint     `gorm:"column:currency_id" json:"currency_id" validate:"required"`
	Currency          Currency `gorm:"foreignKey:currency_id" json:"currency"`
	Status            string   `gorm:"column:status" json:"status" validate:"required"`
	RazorpayPaymentID string   `gorm:"column:razorpay_payment_id" json:"razorpay_payment_id"`
	RazorpaySignature string   `gorm:"column:razorpay_signature" json:"razorpay_signature"`
}

Payment model

func (*Payment) BeforeCreate

func (payment *Payment) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type PaymentEntity

type PaymentEntity struct {
	Entity RazorpayPayment `json:"entity,omitempty"`
}

PaymentEntity razorpay object

type PaymentPayload

type PaymentPayload struct {
	Payment PaymentEntity `json:"payment,omitempty"`
}

PaymentPayload razorpay object

type Plan

type Plan struct {
	Base
	Name        string    `gorm:"column:name" json:"name" validate:"required"`
	Description string    `gorm:"column:description" json:"description"`
	Price       int       `gorm:"column:price" json:"price" validate:"required"`
	Users       int       `gorm:"column:users" json:"users" validate:"required"`
	CurrencyID  uint      `gorm:"column:currency_id" json:"currency_id" validate:"required"`
	Currency    *Currency `gorm:"foreignKey:currency_id"  json:"currency"`
	Duration    uint      `gorm:"column:duration" json:"duration" validate:"required"`
	Status      string    `gorm:"column:status" json:"status" validate:"required"`
	AllProducts bool      `gorm:"column:all_products" json:"all_products"`
	Catalogs    []Catalog `gorm:"many2many:plan_catalog" json:"catalogs"`
}

Plan model

func (*Plan) BeforeCreate

func (plan *Plan) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type Product

type Product struct {
	Base
	Title            string    `gorm:"column:title" json:"title"`
	Description      string    `gorm:"column:description" json:"description"`
	Slug             string    `gorm:"column:slug" json:"slug"`
	Price            int       `gorm:"column:price" json:"price"`
	Status           string    `gorm:"column:status" json:"status"`
	FeaturedMediumID *uint     `gorm:"column:featured_medium_id;default:NULL" json:"featured_medium_id"`
	FeaturedMedium   *Medium   `gorm:"foreignKey:featured_medium_id"  json:"featured_medium"`
	CurrencyID       uint      `gorm:"column:currency_id" json:"currency_id"`
	Currency         Currency  `gorm:"foreignKey:currency_id"  json:"currency"`
	Catalogs         []Catalog `gorm:"many2many:catalog_product;" json:"catalogs"`
	Tags             []Tag     `gorm:"many2many:product_tag;" json:"tags"`
	Datasets         []Dataset `gorm:"many2many:product_dataset;" json:"datasets"`
	Orders           []Order   `gorm:"many2many:order_item;" json:"orders"`
}

Product model

func (*Product) BeforeCreate

func (product *Product) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type RazorpayPayment

type RazorpayPayment struct {
	ID               string        `json:"id,omitempty"`
	Entity           string        `json:"entity,omitempty"`
	Amount           int           `json:"amount,omitempty"`
	Currency         string        `json:"currency,omitempty"`
	Status           string        `json:"status,omitempty"`
	OrderID          string        `json:"order_id,omitempty"`
	InvoiceID        interface{}   `json:"invoice_id,omitempty"`
	International    bool          `json:"international,omitempty"`
	Method           string        `json:"method,omitempty"`
	AmountRefunded   int           `json:"amount_refunded,omitempty"`
	RefundStatus     interface{}   `json:"refund_status,omitempty"`
	Captured         bool          `json:"captured,omitempty"`
	Description      interface{}   `json:"description,omitempty"`
	CardID           interface{}   `json:"card_id,omitempty"`
	Bank             string        `json:"bank,omitempty"`
	Wallet           interface{}   `json:"wallet,omitempty"`
	VPA              interface{}   `json:"vpa,omitempty"`
	Email            string        `json:"email,omitempty"`
	Contact          string        `json:"contact,omitempty"`
	Notes            []interface{} `json:"notes,omitempty"`
	Fee              interface{}   `json:"fee,omitempty"`
	Tax              interface{}   `json:"tax,omitempty"`
	ErrorCode        string        `json:"error_code,omitempty"`
	ErrorDescription string        `json:"error_description,omitempty"`
	ErrorSource      string        `json:"error_source,omitempty"`
	ErrorStep        string        `json:"error_step,omitempty"`
	ErrorReason      string        `json:"error_reason,omitempty"`
	AquirerData      interface{}   `json:"aquirer_data,omitempty"`
	CreatedAt        uint32        `json:"created_at,omitempty"`
}

RazorpayPayment razorpay object

type Role

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

Role in keto

type Tag

type Tag struct {
	Base
	Title    string    `gorm:"column:title" json:"title" validate:"required"`
	Slug     string    `gorm:"column:slug" json:"slug" validate:"required"`
	Products []Product `gorm:"many2many:product_tag;" json:"products"`
	Datasets []Dataset `gorm:"many2many:dataset_tag;" json:"datasets"`
}

Tag model

func (*Tag) BeforeCreate

func (tag *Tag) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook

type User

type User struct {
	Base
	Email     string `gorm:"column:email;unique_index" json:"email"`
	FirstName string `gorm:"column:first_name" json:"first_name"`
	LastName  string `gorm:"column:last_name" json:"last_name"`
	BirthDate string `gorm:"column:birth_date" json:"birth_date"`
	Gender    string `gorm:"column:gender" json:"gender"`
}

User model definition

Jump to

Keyboard shortcuts

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