I'm attempting to create nested objects in mongoDB with no luck the format I am trying to achieve is as follows
"Courses":{
"Date":{
"CourseName" :{
"hole 1"{
}
"hole 2"{
}
...so on until 18
}//coursename
}//date
}//courses
I've tried and succeeded with getting the date object within course by doing the following:
u := req.FormValue("username")
co := req.FormValue("course")
d := req.FormValue("date")
ng := nGame{Username: u, Course: co, Dates: d}
cn := courseName{CName: co}
query := bson.M{"username": u}
update := bson.M{"$push": bson.M{"Course": bson.M{ng.Dates: cn}}}
err = c.Update(query, update)
The date object has the course name inside it what i'm trying to do is make course name another object which then I can insert the hole object.
The Structs i'm using are as follows:
type (
nGame struct {
Username string
Course string
Location string
Dates string
}
)
type (
courseName struct {
CName string
}
)