निम्न का प्रयास करें:
session, err := mgo.Dial("127.0.0.1")
if err != nil {
panic(err)
}
defer session.Close()
session.SetMode(mgo.Monotonic, true)
// Drop Database
if IsDrop {
err = session.DB("test").DropDatabase()
if err != nil {
panic(err)
}
}
// Collection Stack
c := session.DB("test").C("stack")
// Query
query := bson.M{"ownerEmail": "[email protected]"}
update := bson.M{"$push": bson.M{"camps": bson.M{"name": "cubs-killeen", "location": "some other Place"}}}
// Update
err = c.Update(query, update)
if err != nil {
panic(err)
}