store

package
v0.0.0-...-95527fa Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Finalize

func Finalize()

Finalize Finalizes

func Init

func Init() (result bool)

Init inits

Types

type ChartDoc

type ChartDoc struct {
	ID            string    `bson:"_id"`
	TrainSchemaID string    `bson:"trainschema_id"`
	Date          string    `bson:"Date"`
	Availability  []string  `bson:"Availability"`
	TicketIDs     []string  `bson:"traintickets_id"`
	ExpireAt      time.Time `bson:"expireAt"`
	TrainNumber   int       `bson:"TrainNumber"`
}

ChartDoc ChartDoc

func FindChart

func FindChart(trainNum int, date string) (c ChartDoc, err error)

FindChart fetches chart from db

func GetAllCharts

func GetAllCharts() (cArr []ChartDoc, err error)

GetAllCharts fetches trainSchema from db

func (*ChartDoc) AddChart

func (cd *ChartDoc) AddChart() (success bool)

AddChart adds train Chart

type SchemaDoc

type SchemaDoc struct {
	ID           string          `bson:"_id"`
	TrainName    string          `bson:"TrainName"`
	TrainNumber  int             `bson:"TrainNumber"`
	Frequency    []string        `bson:"Frequency"`
	Availability []TicketSchema  `bson:"Availability"`
	Stops        []StationSchema `bson:"Stops"`
}

SchemaDoc SchemaDoc

func FindMatchSchema

func FindMatchSchema(from string, to string, day string) (sArr []SchemaDoc, err error)

FindMatchSchema FindMatchSchema

func FindSchema

func FindSchema(trainNumber int) (s SchemaDoc, err error)

FindSchema fetches trainSchema from db

func GetAllSchema

func GetAllSchema() (sArr []SchemaDoc, err error)

GetAllSchema fetches trainSchema from db

func (*SchemaDoc) AddSchema

func (sd *SchemaDoc) AddSchema() (success bool)

AddSchema adds train schema

type StationSchema

type StationSchema struct {
	Position     int    `bson:"Position"`
	Name         string `bson:"Name"`
	Arrive       string `bson:"Arive"`
	ArriveOffset int    `bson:"ArriveOffset"`
	Depart       string `bson:"Depart"`
	DepartOffset int    `bson:"DepartOffset"`
}

StationSchema StationSchema

func (*StationSchema) GetArriveTime

func (ss *StationSchema) GetArriveTime(date string) time.Time

GetArriveTime GetArriveTime

func (*StationSchema) GetDepartTime

func (ss *StationSchema) GetDepartTime(date string) time.Time

GetDepartTime GetArriGetDepartTimeveTime

type TicketSchema

type TicketSchema struct {
	Class      string `bson:"Class"`
	SeatsTotal int    `bson:"Seatstotal"`
	Fare       int    `bson:"Fare"`
}

TicketSchema TicketSchema

type UserDoc

type UserDoc struct {
	Username string
	Passkey  string
	Role     string
	Status   string
}

UserDoc placeholder for User credentials.

func FindUser

func FindUser(username string) (user *UserDoc, err error)

FindUser fetches user from db

func NewUser

func NewUser(username, password string) (user *UserDoc, err error)

NewUser creates a new UserDoc obj

func (*UserDoc) Authenticate

func (user *UserDoc) Authenticate(pwd string) bool

Authenticate authenticates user against input password

func (*UserDoc) RegisterUser

func (user *UserDoc) RegisterUser() (success bool)

RegisterUser adds doc to users collection

func (*UserDoc) UpdateUserPassword

func (user *UserDoc) UpdateUserPassword(newPwd string) (updated bool)

UpdateUserPassword updates password for existing user

func (*UserDoc) UpdateUserStatus

func (user *UserDoc) UpdateUserStatus(newStatus string) (updated bool)

UpdateUserStatus updates password for existing user

Jump to

Keyboard shortcuts

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