From f4e0335a47b812750c71f77b5114d5bec2672733 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Wed, 28 Sep 2022 09:54:28 -0700 Subject: [PATCH] update data structures --- models/cow.go | 24 ++++++++++++++++++++---- models/device.go | 9 +++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 models/device.go diff --git a/models/cow.go b/models/cow.go index c1be719..037f74d 100644 --- a/models/cow.go +++ b/models/cow.go @@ -1,13 +1,29 @@ package models +import ( + "go.mongodb.org/mongo-driver/bson/primitive" +) + // Cow holds the structure for the cow collection in mongo type Cow struct { - ID string `json:"_id" bson:"_id"` - Details CowDetails `json:"cow" bson:"cow"` + ID string `json:"_id" bson:"_id"` // MongoDB ID + Details CowDetails `json:"cow" bson:"cow"` // Details } -// CowDetails holds teh structure for the inner cow structure as +// BookDetails holds the checkout details +type BookDetails struct { + Author string `json:"Author" bson:"Author"` // User who booked + Devices []string `json:"Devices" bson:"Devices"` // Array of device mongo ID's + Block string `json:"Block" bson:"Block"` // Block that is booked + Date primitive.DateTime `json:"Date" bson:"Date"` // Date this booking occurs +} + +// CowDetails holds the structure for the inner cow structure as // defined in the cow collection in mongo type CowDetails struct { - CowCode string `json:"CowCode" bson:"CowCode"` + CowCode string `json:"CowCode" bson:"CowCode"` // eg. CA-01 + CollectionType string `json:"CollectionType" bson:"CollectionType"` // eg. Laptop, Ipad, etc + TotalDevices int `json:"TotalDevices" bson:"TotalDevices"` // # of devices in that cart collection + Bookings []BookDetails `json:"Bookings" bson:"Bookings"` // An array of all active bookings (send top 10) + Devices []string `json:"Devices" bson:"Devices"` // Array of device mongo ID's } diff --git a/models/device.go b/models/device.go new file mode 100644 index 0000000..4021945 --- /dev/null +++ b/models/device.go @@ -0,0 +1,9 @@ +package models + +// Device holds the structure for the Device collection in mongo +type Device struct { + ID string `json:"ID" bson:"ID"` // MongoDB ID + Type string `json:"Type" bson:"Type"` // eg. Laptop, Ipdad, etc + Code string `json:"Code" bson:"Code"` // eg. SULH-LAP-01 + Parent string `json:"Parent" bson:"Parent"` // Parent cow Mongo ID +}