model

package
v1.6.19 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 4 Imported by: 3

Documentation

Overview

Package model contains all the models required for a functional database management system

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorMsg

type ErrorMsg struct {
	HTTPCode int    `structs:"httpResponseCode" json:"-"`
	Message  string `structs:"msg" json:"msg"`
}

ErrorMsg - to handle HTML + JSON

type Geocoding

type Geocoding struct {
	ID               primitive.ObjectID `json:"id" bson:"_id"`
	FormattedAddress string             `json:"formattedAddress,omitempty" bson:"formattedAddress,omitempty"`
	StreetName       string             `json:"streetName,omitempty" bson:"streetName,omitempty"`
	HouseNumber      string             `json:"houseNumber,omitempty" bson:"houseNumber,omitempty"`
	PostalCode       string             `json:"postalCode,omitempty" bson:"postalCode,omitempty"`
	County           string             `json:"county,omitempty" bson:"county,omitempty"`
	City             string             `json:"city,omitempty" bson:"city,omitempty"`
	State            string             `json:"state,omitempty" bson:"state,omitempty"`
	StateCode        string             `json:"stateCode,omitempty" bson:"stateCode,omitempty"`
	Country          string             `json:"country,omitempty" bson:"country,omitempty"`
	CountryCode      string             `json:"countryCode,omitempty" bson:"countryCode,omitempty"`
	Geometry         Geometry           `json:"geometry,omitempty" bson:"inline"`
}

Geocoding - struct for address

func (Geocoding) IsEmpty

func (s Geocoding) IsEmpty() bool

IsEmpty - check empty struct

type Geometry

type Geometry struct {
	Latitude  float64 `json:"lat,omitempty" bson:"lat,omitempty"`
	Longitude float64 `json:"lng,omitempty" bson:"lng,omitempty"`
}

Geometry - struct for latitude and longitude

type Hobby

type Hobby struct {
	HobbyID   uint64         `gorm:"primaryKey" json:"hobbyID,omitempty"`
	CreatedAt time.Time      `json:"createdAt,omitempty"`
	UpdatedAt time.Time      `json:"updatedAt,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Hobby     string         `json:"hobby,omitempty"`
	Users     []User         `gorm:"many2many:user_hobbies" json:"-"`
}

Hobby model - `hobbies` table

type Post

type Post struct {
	PostID    uint64         `gorm:"primaryKey" json:"postID,omitempty" structs:"postID,omitempty"`
	CreatedAt time.Time      `json:"createdAt,omitempty" structs:"createdAt,omitempty"`
	UpdatedAt time.Time      `json:"updatedAt,omitempty" structs:"updatedAt,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Title     string         `json:"title,omitempty" structs:"title,omitempty"`
	Body      string         `json:"body,omitempty" structs:"body,omitempty"`
	IDUser    uint64         `json:"-"`
}

Post model - `posts` table

type RedisData

type RedisData struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

RedisData - key:value

type RedisDataHash

type RedisDataHash struct {
	Key   string             `json:"key,omitempty"`
	Value RedisDataHashValue `json:"value,omitempty"`
}

RedisDataHash - key:hashValues

type RedisDataHashValue

type RedisDataHashValue struct {
	Value1 string `json:"value1,omitempty"`
	Value2 string `json:"value2,omitempty"`
	Value3 string `json:"value3,omitempty"`
	Value4 string `json:"value4,omitempty"`
}

RedisDataHashValue - values

type User

type User struct {
	UserID    uint64         `gorm:"primaryKey" json:"userID,omitempty"`
	CreatedAt time.Time      `json:"createdAt,omitempty"`
	UpdatedAt time.Time      `json:"updatedAt,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	FirstName string         `json:"firstName,omitempty"`
	LastName  string         `json:"lastName,omitempty"`
	IDAuth    uint64         `json:"-"`
	Posts     []Post         `gorm:"foreignkey:IDUser;references:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"posts,omitempty"`
	Hobbies   []Hobby        `gorm:"many2many:user_hobbies" json:"hobbies,omitempty"`
}

User model - `users` table

type UserHobby

type UserHobby struct{}

UserHobby model - intermediate table `user_hobbies` (many to many relations)

Jump to

Keyboard shortcuts

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