models

package
v0.0.0-...-22b9301 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct {
	ID              primitive.ObjectID `bson:"_id,omitempty"`
	TemplateID      primitive.ObjectID `bson:"template_id"`
	Username        string             `bson:"username"`
	CreatedAt       time.Time          `bson:"created_at"`
	QuestionAnswers []QuestionAnswer   `bson:"questions,omitempty"`
}

func (Answer) FromForm

func (a Answer) FromForm(templateID primitive.ObjectID, username string, questionAnswers []QuestionAnswer) Answer

func (Answer) Save

func (a Answer) Save(database *mongo.Database) string

type Question

type Question struct {
	ID      primitive.ObjectID `bson:"_id,omitempty"`
	Label   string             `bson:"label"`
	Type    QuestionType       `bson:"type"`
	Options []string           `bson:"options,omitempty"`
	Min     int                `bson:"min,omitempty"`
	Max     int                `bson:"max,omitempty"`
	Order   int                `bson:"order"`
}

func QuestionsFromForm

func QuestionsFromForm(formValues url.Values) []Question

func (Question) OrderToString

func (q Question) OrderToString() string

type QuestionAnswer

type QuestionAnswer struct {
	QuestionID primitive.ObjectID `bson:"question_id"`
	Answer     string             `bson:"answer"`
}

type QuestionType

type QuestionType string
const (
	TextQuestion     QuestionType = "text"
	NumberQuestion   QuestionType = "number"
	RangeQuestion    QuestionType = "range"
	SelectQuestion   QuestionType = "select"
	RadioQuestion    QuestionType = "radio"
	TextAreaQuestion QuestionType = "text_area"
	CheckboxQuestion QuestionType = "checkbox"
)

type Template

type Template struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	Title       string             `bson:"title"`
	Description string             `bson:"description"`
	CreatedAt   time.Time          `bson:"created_at"`
	Username    string             `bson:"username"`
	Questions   []Question         `bson:"questions,omitempty"`
}

func GetTemplate

func GetTemplate(database *mongo.Database, id string) Template

func (Template) FromForm

func (t Template) FromForm(formValues url.Values) Template

func (Template) Save

func (t Template) Save(database *mongo.Database) string

type User

type User struct {
	Username string `bson:"username" form:"username"`
	Password string `bson:"password" form:"password"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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