// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: notifications.sql package sqlcdb import ( "context" "time" ) const createNotification = `-- name: CreateNotification :exec INSERT 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 :many SELECT id, recipient_did, actor_did, type, subject_uri, created_at, read_at FROM notifications WHERE recipient_did = $1 ORDER BY created_at DESC LIMIT $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 :one SELECT 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 :exec UPDATE 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 }