Beispiel #1
0
func (this *CCMomentHandler) DeleteMoment(c *gin.Context) {
	this.Load()
	fmt.Println("Deleting  Moments - ")
	filter := util.ExtractMomentFilter(c)
	err := dbObj.Remove(filter)
	if err != nil {
		fmt.Println("Unable to remove data - ", err.Error())
	}
}
Beispiel #2
0
func (this *CCMomentHandler) FetchAllMoments(c *gin.Context) models.Moment_List {
	this.Load()
	fmt.Println("Fetching all Moments - ")
	filter := util.ExtractMomentFilter(c)
	results := []models.CCMoment{}
	err := dbObj.Find(filter).All(&results)
	if err != nil {
		fmt.Println("Unable to fetch data - ", err.Error())
	}
	var moments []models.Moment
	for i := 0; i < len(results); i++ {
		momentModel := this.LoadModel(results[i])
		moments = append(moments, momentModel)
	}

	momentList := models.Moment_List{Moments: moments}
	return momentList
}