func (t *TypesController) InsertInTypeHandler(c *gin.Context) { appId := c.Param("appId") typeName := c.Param("typeName") body := utils.GetBody(c) d := db.NewTypeDbService(appId, typeName) err := d.Insert(body) if err != nil { RestError(c, err) return } RespondId(body["_id"], c) }
func (t *TypesController) UpdateTypeItemById(c *gin.Context) { appId := c.Param("appId") typeName := c.Param("typeName") itemId := c.Param("itemId") d := db.NewTypeDbService(appId, typeName) body := utils.GetBody(c) err := d.UpdateId(itemId, body) if err != nil { RestError(c, err) return } }
func (t *TypesController) CreateTypeHandler(c *gin.Context) { body := utils.GetBody(c) typeName := body["name"] app := c.MustGet("app").(JSON) d := db.NewAppsDbService(c.MustGet("user").(string)) d.UpdateId(app["_id"], JSON{ "$push": JSON{ "types": typeName, }, }, ) }
func (a *ApplicationController) UpdateApplicationHandler(c *gin.Context) { appId := c.MustGet("app").(JSON)["_id"] d := db.NewAppsDbService(c.MustGet("user").(string)) doc := utils.WhitelistFields([]string{"name"}, utils.GetBody(c)) err := d.Update(JSON{ "_id": appId, }, JSON{ "$set": doc, }) if err != nil { RestError(c, err) return } }
func (a *ApplicationController) UpdateApplicationHandler(w rest.ResponseWriter, r *rest.Request) { appId := r.PathParam("appId") db := neutrino.NewAppsDbService(r.Env["user"].(string)) doc := utils.WhitelistFields([]string{"name"}, utils.GetBody(r)) err := db.Update(bson.M{ "_id": appId, }, bson.M{ "$set": doc, }) if err != nil { RestError(w, err) return } w.WriteHeader(http.StatusOK) }