fyp/logic/models/list.go

27 lines
498 B
Go

package models
import (
"git.andr3h3nriqu3s.com/andr3/fyp/logic/utils"
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/utils"
)
func handleList(handle *Handle) {
handle.Get("/models", func(c *Context) *Error {
if !c.CheckAuthLevel(1) {
return nil
}
type Row struct {
Name string `json:"name"`
Id string `json:"id"`
}
got, err := utils.GetDbMultitple[Row](c, "models where user_id=$1", c.User.Id)
if err != nil {
return c.Error500(nil)
}
return c.SendJSON(got)
})
}