package logrepository

import (
	adsdomain "legalgo-BE-go/internal/domain/ads"
)

func (a *accessor) GetAllLogAds(userID string) ([]adsdomain.Ads, error) {
	var ads []adsdomain.Ads

	// if err := a.db.Find(&ads, "user_id = ?", userID).Error; err != nil {
	// 	return ads, err
	// }

	if err := a.db.
		Joins("JOIN log_ads ON ads.id = log_ads.ads_id").
		Find(&ads, "log_ads.user_id = ?", userID).Error; err != nil {
		return ads, err
	}

	return ads, nil
}
