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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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;
-- name: DeleteAnnotation :execDELETE FROM annotations WHERE uri = $1;
-- name: UpdateAnnotation :execUPDATE annotationsSET body_value = $1, tags_json = $2, cid = $3, indexed_at = $4WHERE uri = $5;
-- 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;
-- 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;
-- 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;
-- 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;
-- 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[]);
-- name: GetAnnotationURIs :manySELECT uri FROM all_annotations WHERE author_did = $1;