models

package
v0.0.0-...-0198dfa Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRankName

func GetRankName(rank int) string

GetRankName ...

Types

type AlertModel

type AlertModel struct{}

AlertModel ...

func (AlertModel) Create

func (model AlertModel) Create(alertType AlertType) (*mongo.InsertOneResult, error)

Create ...

func (AlertModel) DeleteByID

func (model AlertModel) DeleteByID(id primitive.ObjectID) (*mongo.UpdateResult, error)

DeleteByID ...

func (AlertModel) FindByID

func (model AlertModel) FindByID(id primitive.ObjectID) (AlertType, error)

FindByID ...

func (AlertModel) FindByName

func (model AlertModel) FindByName(name string) (AlertType, error)

FindByName ...

func (AlertModel) FindMany

func (model AlertModel) FindMany(q bson.M) ([]AlertType, error)

FindMany ...

func (AlertModel) UpdateByID

func (model AlertModel) UpdateByID(id primitive.ObjectID, alertType AlertType) (*mongo.UpdateResult, error)

UpdateByID exposes a function to update an entry by it's ID

type AlertType

type AlertType struct {
	ID      primitive.ObjectID `json:"_id" bson:"_id"`
	Name    string             `json:"name" bson:"name" validate:"required"`
	Level   int                `json:"level" bson:"level" validate:"required"`
	Status  string             `json:"status" bson:"status"`
	Created time.Time          `json:"created" bson:"created"`
	Updated time.Time          `json:"updated" bson:"updated"`
}

AlertType ...

type Entry

type Entry struct {
	ID          primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	Title       string             `json:"title" bson:"title" validate:"required"`
	Description string             `json:"description" bson:"description" validate:"required"`
	UploadedBy  interface{}        `json:"uploadedBy" bson:"uploadedBy"`
	ContentURL  string             `json:"contentURL" bson:"contentURL" validate:"required"`
	ContentType string             `json:"contentType" bson:"contentType" validate:"required"`
	Location    Location           `json:"location" bson:"location" validate:"required"`
	Address     *geo.Address       `json:"address" bson:"address"`
	AlertType   primitive.ObjectID `json:"alertType" bson:"alertType"`
	Status      string             `json:"status" bson:"status"`
	Created     time.Time          `json:"created" bson:"created"`
	Updated     time.Time          `json:"updated" bson:"updated"`
}

func GetDefaultEntry

func GetDefaultEntry() *Entry

GetDefaultEntry sets the defaults for entries

type Location

type Location struct {
	Type        string     `json:"type" bson:"type"`
	Coordinates [2]float64 `json:"coordinates" bson:"coordinates"`
}

type LocationRanking

type LocationRanking struct {
	Average      float64 `json:"average" bson:"average"`
	Text         string  `json:"text" bson:"text"`
	NumIncidents int32   `json:"numIncidents" bson:"numIncidents"`
}

LocationRanking ...

type Ranking

type Ranking struct {
	Rank         int       `json:"rank" bson:"rank"`
	IsTopAlpha   bool      `json:"isTopAlpha" bson:"isTopAlpha"`
	NumIncidents int32     `json:"numIncidents" bson:"numIncidents"` // only relevant if the user is the top alpha
	LastUpdated  time.Time `json:"lastUpdated" bson:"lastUpdated"`
}

Ranking ...

type User

type User struct {
	ID        primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	Username  string             `json:"username" bson:"username" validate:"required"`
	Email     string             `json:"email" bson:"email" validate:"required,email"`
	Password  string             `json:"password,omitempty" bson:"password" validate:"required"`
	IsAdmin   bool               `json:"isAdmin" bson:"isAdmin"`
	Ranking   Ranking            `json:"ranking" bson:"ranking"`
	AdminRole string             `json:"adminRole,omitempty" bson:"adminRole"` // super, standard
	Status    string             `json:"status" bson:"status"`
	Created   time.Time          `json:"created" bson:"created"`
	Updated   time.Time          `json:"updated" bson:"updated"`
}

User ...

func GetDefaultUser

func GetDefaultUser() *User

GetDefaultUser sets the defaults for users

Jump to

Keyboard shortcuts

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