model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package model defines data models used in the app

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateTimer

func ValidateTimer(t *Timer) error

ValidateTimer validates the given value of Timer.

func ValidateTimerCore

func ValidateTimerCore(tc *TimerCore) error

ValidateTimerCore validates the given value of TimerCore.

Types

type Model

type Model struct {
	ID        uint      `json:"-" gorm:"primarykey"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"-"`
}

Model is the slightly-updated version of gorm.Model It will be managed automatically by gorm.

type Timer

type Timer struct {
	Model
	TimerCore
	Alive     bool           `json:"-" gorm:"index:uniq_name_alive,unique,priority:2"`
	DeletedAt gorm.DeletedAt `json:"-"`
}

Timer is the data model for RESTful resource timer.

func (*Timer) TableName

func (t *Timer) TableName() string

TableName tells gorm the name of the corresponding database table.

type TimerCore

type TimerCore struct {
	Name      string    `json:"name" gorm:"index:uniq_name_alive,unique,priority:1" validate:"required,notblank"`
	TriggerAt time.Time `json:"triggerAt" gorm:"index:idx_trigger_at" validate:"required,gte=time.Now().Add(time.Minute),notblank"`
}

TimerCore contains fields that can be specified directly via APIs.

Jump to

Keyboard shortcuts

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