schema

package
v0.0.0-...-b182c15 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Schema = graphql.MustParseSchema(schemaString, &RootResolver{}, opts...)
)

Functions

This section is empty.

Types

type Contact

type Contact struct {
	FirstName string
	LastName  string
	Address   string
	City      string
	State     string
	Zip       string
}

type Customer

type Customer struct {
	PK         string
	SK         string
	GSI2PK     string
	Phone      string // Customer's unique key.
	StorePhone string // Foreign key to customer's store.
	Contact    Contact
}

func CustomerFromJSON

func CustomerFromJSON(jsonSrc string) (cus *Customer, err error)

func GetCustomer

func GetCustomer(phone string) (cus Customer, err error)

func (*Customer) Init

func (c *Customer) Init()

func (*Customer) MakeGSI2PK

func (c *Customer) MakeGSI2PK() string

func (*Customer) MakePK

func (c *Customer) MakePK() string

func (*Customer) MakeSK

func (c *Customer) MakeSK() string

func (Customer) Put

func (c Customer) Put() error

func (Customer) PutRental

func (c Customer) PutRental() (CustomerRental, error)

func (Customer) Store

func (c Customer) Store() (Store, error)

type CustomerRental

type CustomerRental struct {
	PK    string
	SK    string
	Phone string
	Date  time.Time
}

CustomerRental represents an occasion when the customer rented movies.

func (*CustomerRental) Init

func (cr *CustomerRental) Init()

func (*CustomerRental) MakePK

func (cr *CustomerRental) MakePK() string

func (*CustomerRental) MakeSK

func (cr *CustomerRental) MakeSK() string

type Info

type Info struct {
	Directors       []string
	ReleaseDate     time.Time `json:"release_date" dynamodbav:"ReleaseDate"`
	Rating          float64
	Genres          []string
	ImageURL        string `json:"image_url" dynamodbav:"ImageURL"`
	Plot            string
	Rank            int32
	RunningTimeSecs int `json:"running_time_secs" dynamodbav:"RunningTimeSecs"`
	Actors          []string
}

type Location

type Location struct {
	Address string
	City    string
	State   string
	Zip     string
}

type Movie

type Movie struct {
	PK    string
	SK    string
	Year  int32
	Title string
	Info  Info
}

func GetMovie

func GetMovie(year int32, title string) (mov Movie, err error)

func MovieFromJSON

func MovieFromJSON(jsonSrc string) (movie *Movie, err error)

func ScanMovies

func ScanMovies() ([]Movie, error)

Scan the table for all movie INFO items.

func (*Movie) Init

func (m *Movie) Init()

func (*Movie) MakePK

func (m *Movie) MakePK() string

func (*Movie) MakeSK

func (m *Movie) MakeSK() string

func (*Movie) Put

func (m *Movie) Put() error

func (Movie) PutRental

func (m Movie) PutRental(phone string, date time.Time) (MovieRental, error)

type MovieRental

type MovieRental struct {
	PK         string
	SK         string
	Year       int32     // part of pkey to Movie
	Title      string    // part of pkey to Movie
	Phone      string    // Part of fkey to CustomerRental
	Date       time.Time // Part of fkey to CustomerRental
	DueDate    time.Time
	ReturnDate time.Time
}

MovieRental represents a movie that was part of a CustomerRental

func (*MovieRental) Init

func (mr *MovieRental) Init()

func (*MovieRental) MakePK

func (mr *MovieRental) MakePK() string

func (*MovieRental) MakeSK

func (mr *MovieRental) MakeSK() string

type RootResolver

type RootResolver struct{}

func (*RootResolver) Customer

func (r *RootResolver) Customer(args struct{ Phone string }) (Customer, error)

func (*RootResolver) Movie

func (r *RootResolver) Movie(args struct {
	Year  int32
	Title string
}) (Movie, error)

func (*RootResolver) Store

func (r *RootResolver) Store(args struct{ Phone string }) (Store, error)

type Store

type Store struct {
	PK       string
	SK       string
	Phone    string
	Name     string
	Location Location
}

func GetStore

func GetStore(phone string) (sto Store, err error)

func StoreFromJSON

func StoreFromJSON(jsonSrc string) (store *Store, err error)

func (Store) Customers

func (s Store) Customers() ([]Customer, error)

func (*Store) GetMovies

func (s *Store) GetMovies(year int32, title string) ([]StoreMovie, error)

Movies returns the store's inventory. The year and title can be used to constrain the results, but because we apply this constraint to the sort key, the year must be specified, and if title is specied, any movie titles with that prefix will be returned. Obviously, this is only an exercise in DDB query techniques, and very much not a practical general-purpose search capability.

func (*Store) Init

func (s *Store) Init()

func (*Store) MakePK

func (s *Store) MakePK() string

func (*Store) MakeSK

func (s *Store) MakeSK() string

func (Store) Movies

func (s Store) Movies(args struct {
	Year  int32
	Title string
}) ([]StoreMovie, error)

func (*Store) Put

func (s *Store) Put() error

func (Store) PutMovie

func (s Store) PutMovie(year int32, title string, count int32) error

type StoreMovie

type StoreMovie struct {
	PK    string
	SK    string
	Phone string // Pkey to Store
	Year  int32  // Pkey to Movie
	Title string // Pkey to Movie
	Count int32
}

StoreMovie represents the copies of a movie in a store's inventory.

func (StoreMovie) GetMovie

func (sm StoreMovie) GetMovie() (mov Movie, err error)

func (*StoreMovie) Init

func (sm *StoreMovie) Init()

func (*StoreMovie) MakePK

func (sm *StoreMovie) MakePK() string

func (*StoreMovie) MakeSK

func (sm *StoreMovie) MakeSK() string

func (*StoreMovie) Put

func (sm *StoreMovie) Put() error

Jump to

Keyboard shortcuts

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