Exemple #1
0
func (this *User) Post(c *gin.Context) {
	//c.JSON(200, gin.H{"user_name": "Mojo Jojo"})

	s := util.GetDBSession()
	defer s.Close()

	newUser := models.User{"Tin", "Man"}
	s.DB("lego").C("user").Insert(newUser)
}
Exemple #2
0
func (this *CCProgramHandler) DeleteProgram(c *gin.Context) {
	fmt.Println("Deleting  Programs - ")
	session := util.GetDBSession()
	dbObj := session.DB(util.DB_Name).C(util.DB_Program)

	filter := util.ExtractProgramFilter(c)
	err := dbObj.Remove(filter)
	if err != nil {
		fmt.Println("Unable to remove data - ", err.Error())
	}
}
Exemple #3
0
func (this *User) Get(c *gin.Context) {

	s := util.GetDBSession()
	defer s.Close()

	results := []models.User{}

	err := s.DB("lego").C("user").Find(nil).All(&results)
	if err != nil {
		fmt.Println("some error ", err)
	}
	fmt.Println("Results All: ", results)
	fmt.Println(util.Glo_variable)
	c.JSON(200, results)
}
Exemple #4
0
func (this *CCAuthHandler) Load() {
	// Load DB Object
	fmt.Println("Loads Db")
	session = util.GetDBSession()
	dbObj = session.DB(util.DB_Name).C(util.DB_User)
}
Exemple #5
0
func (this *CCMomentHandler) Load() {
	// Load DB Object
	fmt.Println("Loads Db")
	session = util.GetDBSession()
	dbObj = session.DB(util.DB_Name).C(util.DB_Event_Moment)
}