fix device details name and capitalize database queries
This commit is contained in:
1 parent
aca61eea25
commit
10bc974d2d
2 files changed
+3
-3
No files matched your search
@@ -163,7 +163,7 @@ func (d Device) UpdateDeviceHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
varName := e.Type().Field(i).Name
|
varName := e.Type().Field(i).Name
|
||||||
varValue := e.Field(i).Interface()
|
varValue := e.Field(i).Interface()
|
||||||
if varValue != nil && varValue != "" {
|
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"]
|
cowID := mux.Vars(r)["cow_id"]
|
||||||
defer cancel()
|
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 there is no devices from the query, return empty device array.
|
||||||
if len(devices) == 0 {
|
if len(devices) == 0 {
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package models
|
|||||||
// Device holds the structure for the device collection in mongo
|
// Device holds the structure for the device collection in mongo
|
||||||
type Device struct {
|
type Device struct {
|
||||||
ID string `json:"_id" bson:"_id"` // MongoDB ID
|
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
|
// Device holds the structure for the Device collection in mongo
|
||||||
|
|||||||
Reference in new issue
Block a user