package services

import (
	"go-account-register/models"
	"go-account-register/utils"

	"gorm.io/gorm"
)

type TwitterPostService struct {
	db *gorm.DB
}

func InitTwitterPostService() *TwitterPostService {
	db := utils.GetDB()
	return &TwitterPostService{db: db}
}

func (s *TwitterPostService) GetAll() []models.TwitterPost {
	var post []models.TwitterPost
	res := s.db.Model(&models.TwitterPost{}).Where(`status = ? `, 1)

	res.Order("id DESC").Find(&post)
	return post
}
