Added getPictures and getPicturesByUserId func

master
Alex 2021-08-10 12:34:16 +02:00
parent 4026a40fa1
commit 6924c9ddbf
1 changed files with 14 additions and 4 deletions

View File

@ -73,11 +73,21 @@ func Save(c *fiber.Ctx) error {
func GetPictures(c *fiber.Ctx) error { func GetPictures(c *fiber.Ctx) error {
db := database.DB db := database.DB
log.Info("here") pictures := []map[string]interface{}{}
pictures := &[]structs.Picture{} db.Model(structs.Picture{}).Select("user_id", "picture_id", "likes", "description").Find(&pictures)
db.Find(pictures) return c.JSON(pictures)
}
func GetPicturesByUserId(c *fiber.Ctx) error {
db := database.DB
log.Infoln("")
pictures := []structs.APIPicture{}
db.Model(structs.Picture{}).Where("user_id", c.Params("id")).Find(&pictures)
return c.JSON(pictures) return c.JSON(pictures)
} }