Fix model issues.

This commit is contained in:
2025-10-30 22:19:48 +00:00
parent 262536135d
commit a7a5169c67
5 changed files with 11 additions and 11 deletions

View File

@@ -35,14 +35,15 @@ func New(db *sql.DB, opts ...func(*Service)) *Service {
func WithTimeout(d time.Duration) func(*Service) { return func(s *Service) { s.Timeout = d } }
// List returns newest-first notifications for a user.
// ToDo:table is users_notification, where as messages is plural, this table seems oto use user_id reather than userId need to unify. Do i want to prefix with users/user
func (s *Service) List(userID int64) ([]domain.Notification, error) {
ctx, cancel := context.WithTimeout(context.Background(), s.Timeout)
defer cancel()
const q = `
SELECT id, title, body, is_read, created_at
FROM notifications
WHERE userId = ?
FROM users_notification
WHERE user_Id = ?
ORDER BY created_at DESC`
rows, err := s.DB.QueryContext(ctx, q, userID)