Exemplo n.º 1
0
func (m *MgoQuestionStore) UpdateAnswer(questionID string, ans *model.Answer) error {
	ans.SetUpdated()
	return m.c.Update(bson.M{"_id": questionID,
		"Answers._id": ans.ID}, bson.M{"$set": bson.M{"Answers.$": ans,
		"UpdatedAt": ans.UpdatedAt}})
}
Exemplo n.º 2
0
func (m *MgoQuestionStore) AddAnswer(questionID string, ans *model.Answer) error {
	ans.SetNew()
	return m.c.UpdateId(questionID, bson.M{"$push": bson.M{
		"Answers": ans,
	}, "UpdatedAt": ans.UpdatedAt})
}