My structure
struct task {
Id *bson.ObjectId `json:"id" bson:"_id,omitempty"`
Text string `json:"text" bson:"text,omitempty"`
// other params
}
Get data from form
var task Task{}
task.Text = FORM.Text
and my function to find tasks
func FindOne(task Task) (Task, error) {
err := db.Session.DB("tasks").C(CollectionTask).Find(&task).One(&task)
if err != nil {
return task, err
}
return task, nil
}
From the search form I only get a line text
, without a fieldid
, in this case, _id -> nil and mgo (mongo) finds nothing not found
How do I modify the search function or structure of the data to carry out a correct search?