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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271// Code generated by sqlc. DO NOT EDIT.// versions:// sqlc v1.31.1// source: replies.sql
package sqlcdb
import ( "context" "time")
const createReply = `-- name: CreateReply :execINSERT INTO replies (uri, author_did, parent_uri, root_uri, text, format, created_at, indexed_at, cid)VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)ON CONFLICT(uri) DO UPDATE SET text = EXCLUDED.text, format = EXCLUDED.format, indexed_at = EXCLUDED.indexed_at, cid = EXCLUDED.cid`
type CreateReplyParams struct { Uri string `json:"uri"` AuthorDid string `json:"authorDid"` ParentUri string `json:"parentUri"` RootUri string `json:"rootUri"` Text string `json:"text"` Format *string `json:"format"` CreatedAt time.Time `json:"createdAt"` IndexedAt time.Time `json:"indexedAt"` Cid *string `json:"cid"`}
func (q *Queries) CreateReply(ctx context.Context, arg CreateReplyParams) error { _, err := q.db.Exec(ctx, createReply, arg.Uri, arg.AuthorDid, arg.ParentUri, arg.RootUri, arg.Text, arg.Format, arg.CreatedAt, arg.IndexedAt, arg.Cid, ) return err}
const deleteReply = `-- name: DeleteReply :execDELETE FROM replies WHERE uri = $1`
func (q *Queries) DeleteReply(ctx context.Context, uri string) error { _, err := q.db.Exec(ctx, deleteReply, uri) return err}
const getOrphanedRepliesByAuthor = `-- name: GetOrphanedRepliesByAuthor :manySELECT r.uri, r.author_did, r.parent_uri, r.root_uri, r.text, r.format, r.created_at, r.indexed_at, r.cidFROM replies rLEFT JOIN annotations a ON r.root_uri = a.uriWHERE r.author_did = $1 AND a.uri IS NULL`
func (q *Queries) GetOrphanedRepliesByAuthor(ctx context.Context, authorDid string) ([]Reply, error) { rows, err := q.db.Query(ctx, getOrphanedRepliesByAuthor, authorDid) if err != nil { return nil, err } defer rows.Close() var items []Reply for rows.Next() { var i Reply if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.ParentUri, &i.RootUri, &i.Text, &i.Format, &i.CreatedAt, &i.IndexedAt, &i.Cid, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const getRepliesByAuthor = `-- name: GetRepliesByAuthor :manySELECT uri, author_did, parent_uri, root_uri, text, format, created_at, indexed_at, cidFROM repliesWHERE author_did = $1ORDER BY created_at DESC`
func (q *Queries) GetRepliesByAuthor(ctx context.Context, authorDid string) ([]Reply, error) { rows, err := q.db.Query(ctx, getRepliesByAuthor, authorDid) if err != nil { return nil, err } defer rows.Close() var items []Reply for rows.Next() { var i Reply if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.ParentUri, &i.RootUri, &i.Text, &i.Format, &i.CreatedAt, &i.IndexedAt, &i.Cid, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const getRepliesByRoot = `-- name: GetRepliesByRoot :manySELECT uri, author_did, parent_uri, root_uri, text, format, created_at, indexed_at, cidFROM repliesWHERE root_uri = $1ORDER BY created_at ASC`
func (q *Queries) GetRepliesByRoot(ctx context.Context, rootUri string) ([]Reply, error) { rows, err := q.db.Query(ctx, getRepliesByRoot, rootUri) if err != nil { return nil, err } defer rows.Close() var items []Reply for rows.Next() { var i Reply if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.ParentUri, &i.RootUri, &i.Text, &i.Format, &i.CreatedAt, &i.IndexedAt, &i.Cid, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const getRepliesByURIs = `-- name: GetRepliesByURIs :manySELECT uri, author_did, parent_uri, root_uri, text, format, created_at, indexed_at, cidFROM repliesWHERE uri = ANY($1::text[])`
func (q *Queries) GetRepliesByURIs(ctx context.Context, dollar_1 []string) ([]Reply, error) { rows, err := q.db.Query(ctx, getRepliesByURIs, dollar_1) if err != nil { return nil, err } defer rows.Close() var items []Reply for rows.Next() { var i Reply if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.ParentUri, &i.RootUri, &i.Text, &i.Format, &i.CreatedAt, &i.IndexedAt, &i.Cid, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const getReplyByURI = `-- name: GetReplyByURI :oneSELECT uri, author_did, parent_uri, root_uri, text, format, created_at, indexed_at, cidFROM repliesWHERE uri = $1`
func (q *Queries) GetReplyByURI(ctx context.Context, uri string) (Reply, error) { row := q.db.QueryRow(ctx, getReplyByURI, uri) var i Reply err := row.Scan( &i.Uri, &i.AuthorDid, &i.ParentUri, &i.RootUri, &i.Text, &i.Format, &i.CreatedAt, &i.IndexedAt, &i.Cid, ) return i, err}
const getReplyCount = `-- name: GetReplyCount :oneSELECT COUNT(*) FROM replies WHERE root_uri = $1`
func (q *Queries) GetReplyCount(ctx context.Context, rootUri string) (int64, error) { row := q.db.QueryRow(ctx, getReplyCount, rootUri) var count int64 err := row.Scan(&count) return count, err}
const getReplyCounts = `-- name: GetReplyCounts :manySELECT root_uri, COUNT(*)FROM repliesWHERE root_uri = ANY($1::text[])GROUP BY root_uri`
type GetReplyCountsRow struct { RootUri string `json:"rootUri"` Count int64 `json:"count"`}
func (q *Queries) GetReplyCounts(ctx context.Context, dollar_1 []string) ([]GetReplyCountsRow, error) { rows, err := q.db.Query(ctx, getReplyCounts, dollar_1) if err != nil { return nil, err } defer rows.Close() var items []GetReplyCountsRow for rows.Next() { var i GetReplyCountsRow if err := rows.Scan(&i.RootUri, &i.Count); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil}