Something went wrong. Try again.
(READ ONLY) Margin is an open annotation layer for the internet. Powered by the AT Protocol.
margin.at
extension web atproto comments
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066// Code generated by sqlc. DO NOT EDIT.// versions:// sqlc v1.31.1// source: annotations.sql
package sqlcdb
import ( "context" "time")
const createAnnotation = `-- name: CreateAnnotation :execINSERT 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 :execDELETE 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 :oneSELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE 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 :manySELECT 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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE author_did = $1ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE author_did = $1 AND target_hash = $2ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE motivation = $1ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE lower(tags_json)::jsonb ? $1ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE author_did = $1 AND lower(tags_json)::jsonb ? $2ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE target_hash = $1ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE 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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE uri NOT LIKE '%network.cosmik%'ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE author_did = $1 AND uri NOT LIKE '%network.cosmik%'ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE lower(tags_json)::jsonb ? $1 AND uri NOT LIKE '%network.cosmik%'ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE author_did = $1 AND lower(tags_json)::jsonb ? $2 AND uri NOT LIKE '%network.cosmik%'ORDER BY created_at DESCLIMIT $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 :manySELECT 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.cidFROM all_annotations aLEFT JOIN LATERAL ( SELECT COUNT(*) as cnt FROM likes WHERE subject_uri = a.uri) l ON trueLEFT JOIN LATERAL ( SELECT COUNT(*) as cnt FROM replies WHERE root_uri = a.uri) r ON trueWHERE a.created_at > $1 AND (l.cnt + r.cnt) > 0ORDER BY (l.cnt + r.cnt) DESC, a.created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE uri LIKE '%network.cosmik%'ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE author_did = $1 AND uri LIKE '%network.cosmik%'ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE lower(tags_json)::jsonb ? $1 AND uri LIKE '%network.cosmik%'ORDER BY created_at DESCLIMIT $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 :manySELECT uri, author_did, motivation, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM all_annotationsWHERE author_did = $1 AND lower(tags_json)::jsonb ? $2 AND uri LIKE '%network.cosmik%'ORDER BY created_at DESCLIMIT $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 :manySELECT 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.cidFROM all_annotations aWHERE 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 :execUPDATE annotationsSET body_value = $1, tags_json = $2, cid = $3, indexed_at = $4WHERE 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}