added posts

This commit is contained in:
2025-12-10 17:05:17 +00:00
parent d7978a9303
commit c15b8b9cd8

View File

@@ -15,7 +15,7 @@ type CreatePostInput struct {
func (store *Store) GetPosts(ctx *gin.Context) {
var posts []models.Post
if err := store.DB.Preload("Author").Find(&posts).Error; err != nil {
if err := store.DB.Preload("Author").Order("CreatedAt DESC").Find(&posts).Error; err != nil {
ctx.JSON(http.StatusInternalServerError, err.Error())
return
}