models

package
v0.0.0-...-c95cf46 Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: MIT Imports: 4 Imported by: 2 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// PassengerAccepted means the passenger is in the ride
	PassengerAccepted = "accepted"
	// PassengerInterested means the passenger would like to join the ride
	PassengerInterested = "interested"
	// PassengerRejected means the passenger cannot join the ride
	PassengerRejected = "rejected"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Car

type Car struct {
	ID        string    `json:"id"`
	Make      string    `json:"make"`
	Model     string    `json:"model"`
	Year      int       `json:"year"`
	Color     string    `json:"color"`
	UserID    string    `json:"user_id" db:"user_id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

Car model instance

func (*Car) String

func (c *Car) String() string

func (*Car) Validate

func (c *Car) Validate() []error

Validate validates car before insertion and updates

type CarChangeSet

type CarChangeSet struct {
	Make   *string
	Model  *string
	Year   *int
	Color  *string
	UserID *string // this one you would set in adapter
}

CarChangeSet is an object for updates

type Passenger

type Passenger struct {
	ID          string    `json:"id" db:"id"`
	DriverID    string    `json:"driver_id" db:"driver_id"`
	PassengerID string    `json:"passenger_id" db:"passenger_id"`
	RideID      string    `json:"ride_id" db:"ride_id"`
	Status      string    `json:"status" db:"status"`
	CreatedAt   time.Time `json:"created_at" db:"created_at"`
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at"`
}

Passenger is the entity for the ride passenger relation

func NewPassenger

func NewPassenger(p *PassengerChangeSet) (*Passenger, error)

NewPassenger creates and validates a passenger from a changeset

func (*Passenger) ApplyUpdates

func (p *Passenger) ApplyUpdates(o *PassengerChangeSet) error

ApplyUpdates attempts to update the passenger with the given changes

func (*Passenger) String

func (p *Passenger) String() string

func (*Passenger) Validate

func (p *Passenger) Validate() error

Validate validates the passenger

type PassengerChangeSet

type PassengerChangeSet struct {
	PassengerID *string `json:"passenger_id"`
	RideID      *string `json:"ride_id"`
	Status      *string `json:"status"`
}

PassengerChangeSet is what is allowed to be changed

type Ride

type Ride struct {
	ID              string    `json:"id" db:"id"`
	DriverID        string    `json:"driver_id" db:"driver_id"`
	CarID           string    `json:"car_id" db:"car_id"`
	Seats           int       `json:"seats" db:"seats"`
	SeatsTaken      *int      `json:"seats_taken,omitempty" db:"seats_taken"` //extra detail field
	StartCity       string    `json:"start_city" db:"start_city"`
	EndCity         string    `json:"end_city" db:"end_city"`
	StartLat        float64   `json:"start_dest_lat" db:"start_dest_lat"`
	StartLon        float64   `json:"start_dest_lon" db:"start_dest_lon"`
	EndLat          float64   `json:"end_dest_lat" db:"end_dest_lat"`
	EndLon          float64   `json:"end_dest_lon" db:"end_dest_lon"`
	PricePerSeat    float64   `json:"price_per_seat" db:"price_per_seat"`
	Info            string    `json:"info" db:"info"`
	PassengerStatus *string   `json:"passenger_status,omitempty" db:"passenger_status"` // extra detail field
	StartDate       time.Time `json:"start_date" db:"start_date"`
	CreatedAt       time.Time `json:"created_at" db:"created_at"`
	UpdatedAt       time.Time `json:"updated_at" db:"updated_at"`
}

Ride is a ride entity

func NewRide

func NewRide(r *RideChangeSet) (*Ride, error)

NewRide returns a Ride with the change set fields applied

func (*Ride) ApplyUpdates

func (r *Ride) ApplyUpdates(o *RideChangeSet) error

ApplyUpdates attempts to update ride and validates the updates

func (*Ride) String

func (r *Ride) String() string

String returns a string representation of a ride

func (*Ride) Validate

func (r *Ride) Validate() error

Validate validates a ride

type RideChangeSet

type RideChangeSet struct {
	DriverID     *string   `json:"-"`
	CarID        *string   `json:"car_id"`
	Seats        *int      `json:"seats"`
	StartCity    *string   `json:"start_city"`
	EndCity      *string   `json:"end_city"`
	StartLat     *float64  `json:"start_dest_lat"`
	StartLon     *float64  `json:"start_dest_lon"`
	EndLat       *float64  `json:"end_dest_lat"`
	EndLon       *float64  `json:"end_dest_lon"`
	PricePerSeat *float64  `json:"price_per_seat"`
	Info         *string   `json:"info"`
	StartDate    time.Time `json:"start_date"`
}

RideChangeSet is the fields that are modifiable in the ride

type User

type User struct {
	ID           string    `json:"id"`
	FirstName    string    `json:"first_name" db:"first_name"`
	LastName     string    `json:"last_name" db:"last_name"`
	Email        string    `json:"email"`
	ProfileImage string    `json:"profile_image" db:"profile_image"`
	AuthLevel    int       `json:"auth_level" db:"auth_level"`
	CreatedAt    time.Time `json:"created_at" db:"created_at"`
	UpdatedAt    time.Time `json:"updated_at" db:"updated_at"`
}

User model instance

func (*User) String

func (u *User) String() string

Jump to

Keyboard shortcuts

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