Esempio n. 1
0
File: user.go Progetto: zannet/lego
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)
}
Esempio n. 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())
	}
}
Esempio n. 3
0
File: user.go Progetto: zannet/lego
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)
}
Esempio n. 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)
}
Esempio n. 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)
}