From 10bc974d2dcd5efd78030b4a63bddae415b94849 Mon Sep 17 00:00:00 2001 From: SowinskiBraeden Date: Fri, 21 Oct 2022 17:12:10 -0700 Subject: [PATCH] fix device details name and capitalize database queries --- api/handlers/device.go | 4 ++-- models/device.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/handlers/device.go b/api/handlers/device.go index 72736bb..41cbb6c 100644 --- a/api/handlers/device.go +++ b/api/handlers/device.go @@ -163,7 +163,7 @@ func (d Device) UpdateDeviceHandler(w http.ResponseWriter, r *http.Request) { varName := e.Type().Field(i).Name varValue := e.Field(i).Interface() if varValue != nil && varValue != "" { - update["Device."+varName] = varValue + update["Details."+varName] = varValue } } @@ -188,7 +188,7 @@ func (d Device) GetChildDevices(w http.ResponseWriter, r *http.Request) { cowID := mux.Vars(r)["cow_id"] defer cancel() - devices, _ := d.DB.Find(ctx, bson.M{"detials.parent": cowID}) + devices, _ := d.DB.Find(ctx, bson.M{"Detials.Parent": cowID}) // If there is no devices from the query, return empty device array. if len(devices) == 0 { diff --git a/models/device.go b/models/device.go index 40b2657..9f02c81 100644 --- a/models/device.go +++ b/models/device.go @@ -3,7 +3,7 @@ package models // Device holds the structure for the device collection in mongo type Device struct { ID string `json:"_id" bson:"_id"` // MongoDB ID - Details DeviceDetails `json:"device" bson:"Device"` // Details + Details DeviceDetails `json:"device" bson:"Details"` // Details } // Device holds the structure for the Device collection in mongo