diff options
Diffstat (limited to 'pkg/handler/admin.go')
-rw-r--r-- | pkg/handler/admin.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/handler/admin.go b/pkg/handler/admin.go index 8531011..75fb650 100644 --- a/pkg/handler/admin.go +++ b/pkg/handler/admin.go @@ -55,3 +55,21 @@ func (h *Handler) AdminAction(c echo.Context) error { return c.Redirect(http.StatusFound, "/admin/") } + +func (h *Handler) AdminExport(c echo.Context) error { + quotes := []model.Quote{} + err := h.DB.NewSelect(). + Model((*model.Quote)(nil)). + Order("id ASC"). + Scan(c.Request().Context(), "es) + if err != nil { + return err + } + + quotesString := make([]string, 0, len(quotes)) + for _, q := range quotes { + quotesString = append(quotesString, q.Quote) + } + + return c.JSON(http.StatusOK, quotesString) +} |