// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: annotations.sql package sqlcdb import ( "context" "time" ) const createAnnotation = `-- name: CreateAnnotation :exec INSERT INTO annotations (uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) ON CONFLICT(uri) DO UPDATE SET motivation = EXCLUDED.motivation, body_value = EXCLUDED.body_value, body_format = EXCLUDED.body_format, body_uri = EXCLUDED.body_uri, target_source = EXCLUDED.target_source, target_hash = EXCLUDED.target_hash, target_title = EXCLUDED.target_title, selector_json = EXCLUDED.selector_json, tags_json = EXCLUDED.tags_json, indexed_at = EXCLUDED.indexed_at, cid = EXCLUDED.cid ` type CreateAnnotationParams struct { Uri string `json:"uri"` AuthorDid string `json:"authorDid"` Motivation *string `json:"motivation"` BodyValue *string `json:"bodyValue"` BodyFormat *string `json:"bodyFormat"` BodyUri *string `json:"bodyUri"` TargetSource *string `json:"targetSource"` TargetHash *string `json:"targetHash"` TargetTitle *string `json:"targetTitle"` SelectorJson *string `json:"selectorJson"` TagsJson *string `json:"tagsJson"` CreatedAt time.Time `json:"createdAt"` IndexedAt time.Time `json:"indexedAt"` Cid *string `json:"cid"` } func (q *Queries) CreateAnnotation(ctx context.Context, arg CreateAnnotationParams) error { _, err := q.db.Exec(ctx, createAnnotation, arg.Uri, arg.AuthorDid, arg.Motivation, arg.BodyValue, arg.BodyFormat, arg.BodyUri, arg.TargetSource, arg.TargetHash, arg.TargetTitle, arg.SelectorJson, arg.TagsJson, arg.CreatedAt, arg.IndexedAt, arg.Cid, ) return err } const deleteAnnotation = `-- name: DeleteAnnotation :exec DELETE FROM annotations WHERE uri = $1 ` func (q *Queries) DeleteAnnotation(ctx context.Context, uri string) error { _, err := q.db.Exec(ctx, deleteAnnotation, uri) return err } const getAnnotationByURI = `-- name: GetAnnotationByURI :one SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE uri = $1 ` func (q *Queries) GetAnnotationByURI(ctx context.Context, uri string) (AllAnnotation, error) { row := q.db.QueryRow(ctx, getAnnotationByURI, uri) var i AllAnnotation err := row.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &i.CreatedAt, &i.IndexedAt, &i.Cid, ) return i, err } const getAnnotationURIs = `-- name: GetAnnotationURIs :many SELECT uri FROM all_annotations WHERE author_did = $1 ` func (q *Queries) GetAnnotationURIs(ctx context.Context, authorDid string) ([]string, error) { rows, err := q.db.Query(ctx, getAnnotationURIs, authorDid) if err != nil { return nil, err } defer rows.Close() var items []string for rows.Next() { var uri string if err := rows.Scan(&uri); err != nil { return nil, err } items = append(items, uri) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getAnnotationsByAuthor = `-- name: GetAnnotationsByAuthor :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE author_did = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetAnnotationsByAuthorParams struct { AuthorDid string `json:"authorDid"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetAnnotationsByAuthor(ctx context.Context, arg GetAnnotationsByAuthorParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getAnnotationsByAuthor, arg.AuthorDid, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getAnnotationsByAuthorAndTargetHash = `-- name: GetAnnotationsByAuthorAndTargetHash :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE author_did = $1 AND target_hash = $2 ORDER BY created_at DESC LIMIT $3 OFFSET $4 ` type GetAnnotationsByAuthorAndTargetHashParams struct { AuthorDid string `json:"authorDid"` TargetHash *string `json:"targetHash"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetAnnotationsByAuthorAndTargetHash(ctx context.Context, arg GetAnnotationsByAuthorAndTargetHashParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getAnnotationsByAuthorAndTargetHash, arg.AuthorDid, arg.TargetHash, arg.Limit, arg.Offset, ) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getAnnotationsByMotivation = `-- name: GetAnnotationsByMotivation :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE motivation = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetAnnotationsByMotivationParams struct { Motivation *string `json:"motivation"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetAnnotationsByMotivation(ctx context.Context, arg GetAnnotationsByMotivationParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getAnnotationsByMotivation, arg.Motivation, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getAnnotationsByTag = `-- name: GetAnnotationsByTag :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE lower(tags_json)::jsonb ? $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetAnnotationsByTagParams struct { TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetAnnotationsByTag(ctx context.Context, arg GetAnnotationsByTagParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getAnnotationsByTag, arg.TagsJson, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getAnnotationsByTagAndAuthor = `-- name: GetAnnotationsByTagAndAuthor :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE author_did = $1 AND lower(tags_json)::jsonb ? $2 ORDER BY created_at DESC LIMIT $3 OFFSET $4 ` type GetAnnotationsByTagAndAuthorParams struct { AuthorDid string `json:"authorDid"` TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetAnnotationsByTagAndAuthor(ctx context.Context, arg GetAnnotationsByTagAndAuthorParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getAnnotationsByTagAndAuthor, arg.AuthorDid, arg.TagsJson, arg.Limit, arg.Offset, ) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getAnnotationsByTargetHash = `-- name: GetAnnotationsByTargetHash :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE target_hash = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetAnnotationsByTargetHashParams struct { TargetHash *string `json:"targetHash"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetAnnotationsByTargetHash(ctx context.Context, arg GetAnnotationsByTargetHashParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getAnnotationsByTargetHash, arg.TargetHash, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getAnnotationsByURIs = `-- name: GetAnnotationsByURIs :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE uri = ANY($1::text[]) ` func (q *Queries) GetAnnotationsByURIs(ctx context.Context, dollar_1 []string) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getAnnotationsByURIs, dollar_1) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getMarginAnnotations = `-- name: GetMarginAnnotations :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE uri NOT LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $1 OFFSET $2 ` type GetMarginAnnotationsParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetMarginAnnotations(ctx context.Context, arg GetMarginAnnotationsParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getMarginAnnotations, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getMarginAnnotationsByAuthor = `-- name: GetMarginAnnotationsByAuthor :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE author_did = $1 AND uri NOT LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetMarginAnnotationsByAuthorParams struct { AuthorDid string `json:"authorDid"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetMarginAnnotationsByAuthor(ctx context.Context, arg GetMarginAnnotationsByAuthorParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getMarginAnnotationsByAuthor, arg.AuthorDid, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getMarginAnnotationsByTag = `-- name: GetMarginAnnotationsByTag :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE lower(tags_json)::jsonb ? $1 AND uri NOT LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetMarginAnnotationsByTagParams struct { TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetMarginAnnotationsByTag(ctx context.Context, arg GetMarginAnnotationsByTagParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getMarginAnnotationsByTag, arg.TagsJson, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getMarginAnnotationsByTagAndAuthor = `-- name: GetMarginAnnotationsByTagAndAuthor :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE author_did = $1 AND lower(tags_json)::jsonb ? $2 AND uri NOT LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $3 OFFSET $4 ` type GetMarginAnnotationsByTagAndAuthorParams struct { AuthorDid string `json:"authorDid"` TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetMarginAnnotationsByTagAndAuthor(ctx context.Context, arg GetMarginAnnotationsByTagAndAuthorParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getMarginAnnotationsByTagAndAuthor, arg.AuthorDid, arg.TagsJson, arg.Limit, arg.Offset, ) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getPopularAnnotations = `-- name: GetPopularAnnotations :many SELECT a.uri, a.author_did, a.motivation, a.body_value, a.body_format, a.body_uri, a.target_source, a.target_hash, a.target_title, a.selector_json, a.tags_json, a.created_at, a.indexed_at, a.cid FROM all_annotations a LEFT JOIN LATERAL ( SELECT COUNT(*) as cnt FROM likes WHERE subject_uri = a.uri ) l ON true LEFT JOIN LATERAL ( SELECT COUNT(*) as cnt FROM replies WHERE root_uri = a.uri ) r ON true WHERE a.created_at > $1 AND (l.cnt + r.cnt) > 0 ORDER BY (l.cnt + r.cnt) DESC, a.created_at DESC LIMIT $2 OFFSET $3 ` type GetPopularAnnotationsParams struct { CreatedAt time.Time `json:"createdAt"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetPopularAnnotations(ctx context.Context, arg GetPopularAnnotationsParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getPopularAnnotations, arg.CreatedAt, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getRecentAnnotations = `-- name: GetRecentAnnotations :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations ORDER BY created_at DESC LIMIT $1 OFFSET $2 ` type GetRecentAnnotationsParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetRecentAnnotations(ctx context.Context, arg GetRecentAnnotationsParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getRecentAnnotations, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getSembleAnnotations = `-- name: GetSembleAnnotations :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE uri LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $1 OFFSET $2 ` type GetSembleAnnotationsParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetSembleAnnotations(ctx context.Context, arg GetSembleAnnotationsParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getSembleAnnotations, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getSembleAnnotationsByAuthor = `-- name: GetSembleAnnotationsByAuthor :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE author_did = $1 AND uri LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetSembleAnnotationsByAuthorParams struct { AuthorDid string `json:"authorDid"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetSembleAnnotationsByAuthor(ctx context.Context, arg GetSembleAnnotationsByAuthorParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getSembleAnnotationsByAuthor, arg.AuthorDid, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getSembleAnnotationsByTag = `-- name: GetSembleAnnotationsByTag :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE lower(tags_json)::jsonb ? $1 AND uri LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetSembleAnnotationsByTagParams struct { TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetSembleAnnotationsByTag(ctx context.Context, arg GetSembleAnnotationsByTagParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getSembleAnnotationsByTag, arg.TagsJson, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getSembleAnnotationsByTagAndAuthor = `-- name: GetSembleAnnotationsByTagAndAuthor :many SELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cid FROM all_annotations WHERE author_did = $1 AND lower(tags_json)::jsonb ? $2 AND uri LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $3 OFFSET $4 ` type GetSembleAnnotationsByTagAndAuthorParams struct { AuthorDid string `json:"authorDid"` TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetSembleAnnotationsByTagAndAuthor(ctx context.Context, arg GetSembleAnnotationsByTagAndAuthorParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getSembleAnnotationsByTagAndAuthor, arg.AuthorDid, arg.TagsJson, arg.Limit, arg.Offset, ) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 getShelvedAnnotations = `-- name: GetShelvedAnnotations :many SELECT a.uri, a.author_did, a.motivation, a.body_value, a.body_format, a.body_uri, a.target_source, a.target_hash, a.target_title, a.selector_json, a.tags_json, a.created_at, a.indexed_at, a.cid FROM all_annotations a WHERE a.created_at < $1 AND a.created_at > $2 AND NOT EXISTS (SELECT 1 FROM likes WHERE subject_uri = a.uri) AND NOT EXISTS (SELECT 1 FROM replies WHERE root_uri = a.uri) ORDER BY RANDOM() LIMIT $3 OFFSET $4 ` type GetShelvedAnnotationsParams struct { CreatedAt time.Time `json:"createdAt"` CreatedAt_2 time.Time `json:"createdAt2"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetShelvedAnnotations(ctx context.Context, arg GetShelvedAnnotationsParams) ([]AllAnnotation, error) { rows, err := q.db.Query(ctx, getShelvedAnnotations, arg.CreatedAt, arg.CreatedAt_2, arg.Limit, arg.Offset, ) if err != nil { return nil, err } defer rows.Close() var items []AllAnnotation for rows.Next() { var i AllAnnotation if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.BodyValue, &i.BodyFormat, &i.BodyUri, &i.TargetSource, &i.TargetHash, &i.TargetTitle, &i.SelectorJson, &i.TagsJson, &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 updateAnnotation = `-- name: UpdateAnnotation :exec UPDATE annotations SET body_value = $1, tags_json = $2, cid = $3, indexed_at = $4 WHERE uri = $5 ` type UpdateAnnotationParams struct { BodyValue *string `json:"bodyValue"` TagsJson *string `json:"tagsJson"` Cid *string `json:"cid"` IndexedAt time.Time `json:"indexedAt"` Uri string `json:"uri"` } func (q *Queries) UpdateAnnotation(ctx context.Context, arg UpdateAnnotationParams) error { _, err := q.db.Exec(ctx, updateAnnotation, arg.BodyValue, arg.TagsJson, arg.Cid, arg.IndexedAt, arg.Uri, ) return err }