models

package
v0.0.0-...-e5d75c2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSchemas

func CreateSchemas() error

CreateSchemas delete old schemam before creating new ones

Types

type Connection

type Connection struct {
	*pg.DB
}

Connection defines the database connection that is needed to make a database transaction

func InitDB

func InitDB(config PgConfig) *Connection

InitDB creates a database connection that is used to execute the various database transactions

func (*Connection) CreateRoom

func (config *Connection) CreateRoom(name, roomType string) (Room, error)

CreateRoom makes a database operation to create a new room of the provided type

func (*Connection) CreateUser

func (config *Connection) CreateUser(fname, lname, userType, officeID, livingspaceID string) (UserSpaces, error)

CreateUser create a new user with the provided details

func (*Connection) DeleteRoom

func (config *Connection) DeleteRoom(ID string) (string, error)

DeleteRoom deletes a room given the its ID

func (*Connection) DeleteUser

func (config *Connection) DeleteUser(ID string) (string, error)

DeleteUser deletes the user given their user ID

func (*Connection) DestroyData

func (config *Connection) DestroyData() error

DestroyData recreates the database thus destroying all the data that existed previously

func (*Connection) GetRoom

func (config *Connection) GetRoom(name, ID string) (Room, error)

GetRoom fetches the room details given its ID

func (*Connection) GetRooms

func (config *Connection) GetRooms() ([]Room, error)

GetRooms fetches all rooms that are currently in existence

func (*Connection) GetUser

func (config *Connection) GetUser(fname, lname, ID string) (UserSpaces, error)

GetUser fetches and returns a user associated with the given ID

func (*Connection) GetUsers

func (config *Connection) GetUsers(officeID, livingSpaceID string) ([]User, error)

GetUsers fetches all the users currently in existence

func (*Connection) UpdateRoom

func (config *Connection) UpdateRoom(name, ID string) (string, error)

UpdateRoom updates the name of a given room

func (*Connection) UpdateUser

func (config *Connection) UpdateUser(fname, lname, ID, officeID, livingspaceID string) (string, error)

UpdateUser updates the firstName and the last name to the user whose ID is provided

type PgConfig

type PgConfig struct {
	DBUser     string
	DBName     string
	DBPassword string
}

PgConfig defines the configuration needed to connect to a postgres database instance

type Room

type Room struct {
	Capacity int
	ID       string
	Name     string
	Type     string
}

Room defines the underlying information of a room in Amity room allocation system

type User

type User struct {
	FirstName string
	ID        string
	LastName  string
	Type      string
}

User defines basic details about a user. They can be used to identify a user

type UserSpaces

type UserSpaces struct {
	User
	LivingSpaceID string
	OfficeID      string
}

UserSpaces defines details of the occupants of the room in amity space allocation system

Jump to

Keyboard shortcuts

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