models

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActivityModel = &Model{&Activity{}}
View Source
var DatabaseName = "api_test"
View Source
var MongodbConnection = "mongodb://localhost:27017"
View Source
var UserModel = &Model{&User{}}

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Image    string   `bson:"image" json:"image" xml:"image"`
	Images   []string `bson:"images" json:"images" xml:"images"`
	Title    string   `bson:"title" json:"title" xml:"title"`
	Titles   string   `bson:"titles" json:"titles" xml:"titles"`
	Content  string   `bson:"content" json:"content" xml:"content"`
	Distance string   `bson:"distance" json:"distance" xml:"distance"`
}

func (*Activity) CheckRequired

func (activity *Activity) CheckRequired(data map[string]interface{}) error

func (*Activity) GetCollectionName

func (*Activity) GetCollectionName() string

func (*Activity) GetUnique

func (*Activity) GetUnique() string

func (*Activity) Validate

func (*Activity) Validate(data map[string]any) error

type IModel

type IModel interface {
	GetCollectionName() string
	GetUnique() string
	Validate(map[string]any) error

	CheckRequired(map[string]any) error
}

type Model

type Model struct {
	IModel
}

func (*Model) Delete

func (s *Model) Delete(id string) error

func (*Model) Filter

func (s *Model) Filter(data map[string]interface{}) map[string]interface{}

func (*Model) GetAll

func (s *Model) GetAll() (any, error)

func (*Model) GetById

func (s *Model) GetById(id string) (any, error)

func (*Model) Post

func (s *Model) Post(data map[string]any) error

func (*Model) Put

func (s *Model) Put(id string, data map[string]any) error

Put TODO: Could be reworked so we look in the database first to confirm if item with id exist, before modifying it

type User

type User struct {
	Name string `bson:"name" json:"name" xml:"name"`
	Age  int    `bson:"age" json:"age" xml:"age"`
}

func (*User) CheckRequired

func (*User) CheckRequired(data map[string]interface{}) error

func (*User) GetCollectionName

func (*User) GetCollectionName() string

func (*User) GetUnique

func (*User) GetUnique() string

func (*User) Validate

func (*User) Validate(data map[string]any) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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