-- NOTE: This file is auto generated by ./sql-generator

-- NotificationRepository.cleanup
delete from "notifications"
where
  (
    (
      "deletedAt" is not null
      and "deletedAt" < $1
    )
    or (
      "readAt" > $2
      and "createdAt" < $3
    )
    or (
      "readAt" = $4
      and "createdAt" < $5
    )
  )

-- NotificationRepository.search
select
  "id",
  "createdAt",
  "level",
  "type",
  "title",
  "description",
  "data",
  "readAt"
from
  "notifications"
where
  "userId" = $1
  and "deletedAt" is null
order by
  "createdAt" desc

-- NotificationRepository.search (unread)
select
  "id",
  "createdAt",
  "level",
  "type",
  "title",
  "description",
  "data",
  "readAt"
from
  "notifications"
where
  (
    "userId" = $1
    and "readAt" is null
  )
  and "deletedAt" is null
order by
  "createdAt" desc
