Something went wrong. Try again.
(READ ONLY) Margin is an open annotation layer for the internet. Powered by the AT Protocol.
margin.at
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103// Code generated by sqlc. DO NOT EDIT.// versions:// sqlc v1.31.1// source: notifications.sql
package sqlcdb
import ( "context" "time")
const createNotification = `-- name: CreateNotification :execINSERT INTO notifications (recipient_did, actor_did, type, subject_uri, created_at)VALUES ($1, $2, $3, $4, $5)`
type CreateNotificationParams struct { RecipientDid string `json:"recipientDid"` ActorDid string `json:"actorDid"` Type string `json:"type"` SubjectUri string `json:"subjectUri"` CreatedAt time.Time `json:"createdAt"`}
func (q *Queries) CreateNotification(ctx context.Context, arg CreateNotificationParams) error { _, err := q.db.Exec(ctx, createNotification, arg.RecipientDid, arg.ActorDid, arg.Type, arg.SubjectUri, arg.CreatedAt, ) return err}
const getNotifications = `-- name: GetNotifications :manySELECT id, recipient_did, actor_did, type, subject_uri, created_at, read_atFROM notificationsWHERE recipient_did = $1ORDER BY created_at DESCLIMIT $2 OFFSET $3`
type GetNotificationsParams struct { RecipientDid string `json:"recipientDid"` Limit int32 `json:"limit"` Offset int32 `json:"offset"`}
func (q *Queries) GetNotifications(ctx context.Context, arg GetNotificationsParams) ([]Notification, error) { rows, err := q.db.Query(ctx, getNotifications, arg.RecipientDid, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []Notification for rows.Next() { var i Notification if err := rows.Scan( &i.ID, &i.RecipientDid, &i.ActorDid, &i.Type, &i.SubjectUri, &i.CreatedAt, &i.ReadAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const getUnreadNotificationCount = `-- name: GetUnreadNotificationCount :oneSELECT COUNT(*) FROM notifications WHERE recipient_did = $1 AND read_at IS NULL`
func (q *Queries) GetUnreadNotificationCount(ctx context.Context, recipientDid string) (int64, error) { row := q.db.QueryRow(ctx, getUnreadNotificationCount, recipientDid) var count int64 err := row.Scan(&count) return count, err}
const markNotificationsRead = `-- name: MarkNotificationsRead :execUPDATE notifications SET read_at = $1 WHERE recipient_did = $2 AND read_at IS NULL`
type MarkNotificationsReadParams struct { ReadAt *time.Time `json:"readAt"` RecipientDid string `json:"recipientDid"`}
func (q *Queries) MarkNotificationsRead(ctx context.Context, arg MarkNotificationsReadParams) error { _, err := q.db.Exec(ctx, markNotificationsRead, arg.ReadAt, arg.RecipientDid) return err}