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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311// Code generated by sqlc. DO NOT EDIT.// versions:// sqlc v1.31.1// source: notes.sql
package sqlcdb
import ( "context" "time")
const communityBookmarkExists = `-- name: CommunityBookmarkExists :oneSELECT 1 FROM community_bookmark_refs cbrJOIN notes n ON n.uri = cbr.note_uriWHERE n.author_did = $1 AND n.target_hash = $2LIMIT 1`
type CommunityBookmarkExistsParams struct { AuthorDid string `json:"authorDid"` TargetHash string `json:"targetHash"`}
func (q *Queries) CommunityBookmarkExists(ctx context.Context, arg CommunityBookmarkExistsParams) (int32, error) { row := q.db.QueryRow(ctx, communityBookmarkExists, arg.AuthorDid, arg.TargetHash) var column_1 int32 err := row.Scan(&column_1) return column_1, err}
const createNote = `-- name: CreateNote :execINSERT INTO notes ( uri, author_did, motivation, color, description, 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, $15, $16) ON CONFLICT (uri) DO UPDATE SET motivation = EXCLUDED.motivation, color = EXCLUDED.color, description = EXCLUDED.description, 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 CreateNoteParams struct { Uri string `json:"uri"` AuthorDid string `json:"authorDid"` Motivation *string `json:"motivation"` Color *string `json:"color"` Description *string `json:"description"` 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) CreateNote(ctx context.Context, arg CreateNoteParams) error { _, err := q.db.Exec(ctx, createNote, arg.Uri, arg.AuthorDid, arg.Motivation, arg.Color, arg.Description, 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 deleteCommunityBookmarkRef = `-- name: DeleteCommunityBookmarkRef :execDELETE FROM community_bookmark_refs WHERE note_uri = $1`
func (q *Queries) DeleteCommunityBookmarkRef(ctx context.Context, noteUri string) error { _, err := q.db.Exec(ctx, deleteCommunityBookmarkRef, noteUri) return err}
const deleteNote = `-- name: DeleteNote :execDELETE FROM notes WHERE uri = $1`
func (q *Queries) DeleteNote(ctx context.Context, uri string) error { _, err := q.db.Exec(ctx, deleteNote, uri) return err}
const getCommunityBookmarkURI = `-- name: GetCommunityBookmarkURI :oneSELECT community_uri FROM community_bookmark_refs WHERE note_uri = $1`
func (q *Queries) GetCommunityBookmarkURI(ctx context.Context, noteUri string) (string, error) { row := q.db.QueryRow(ctx, getCommunityBookmarkURI, noteUri) var community_uri string err := row.Scan(&community_uri) return community_uri, err}
const getNoteByURI = `-- name: GetNoteByURI :oneSELECT uri, author_did, motivation, color, description, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM notes WHERE uri = $1`
func (q *Queries) GetNoteByURI(ctx context.Context, uri string) (Note, error) { row := q.db.QueryRow(ctx, getNoteByURI, uri) var i Note err := row.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.Color, &i.Description, &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 getNotesByURIs = `-- name: GetNotesByURIs :manySELECT uri, author_did, motivation, color, description, body_value, body_format, body_uri, target_source, target_hash, target_title, selector_json, tags_json, created_at, indexed_at, cidFROM notes WHERE uri = ANY($1::text[])`
func (q *Queries) GetNotesByURIs(ctx context.Context, dollar_1 []string) ([]Note, error) { rows, err := q.db.Query(ctx, getNotesByURIs, dollar_1) if err != nil { return nil, err } defer rows.Close() var items []Note for rows.Next() { var i Note if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Motivation, &i.Color, &i.Description, &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 marginNoteBookmarkExists = `-- name: MarginNoteBookmarkExists :oneSELECT 1 FROM notesWHERE author_did = $1 AND target_hash = $2 AND motivation = 'bookmarking' AND uri LIKE 'at://%/at.margin.note/%'LIMIT 1`
type MarginNoteBookmarkExistsParams struct { AuthorDid string `json:"authorDid"` TargetHash string `json:"targetHash"`}
func (q *Queries) MarginNoteBookmarkExists(ctx context.Context, arg MarginNoteBookmarkExistsParams) (int32, error) { row := q.db.QueryRow(ctx, marginNoteBookmarkExists, arg.AuthorDid, arg.TargetHash) var column_1 int32 err := row.Scan(&column_1) return column_1, err}
const saveCommunityBookmarkRef = `-- name: SaveCommunityBookmarkRef :execINSERT INTO community_bookmark_refs (note_uri, community_uri)VALUES ($1, $2)ON CONFLICT (note_uri) DO UPDATE SET community_uri = EXCLUDED.community_uri`
type SaveCommunityBookmarkRefParams struct { NoteUri string `json:"noteUri"` CommunityUri string `json:"communityUri"`}
func (q *Queries) SaveCommunityBookmarkRef(ctx context.Context, arg SaveCommunityBookmarkRefParams) error { _, err := q.db.Exec(ctx, saveCommunityBookmarkRef, arg.NoteUri, arg.CommunityUri) return err}
const updateNoteAnnotation = `-- name: UpdateNoteAnnotation :execUPDATE notesSET body_value = $1, tags_json = NULLIF($2, ''), cid = $3, indexed_at = $4WHERE uri = $5`
type UpdateNoteAnnotationParams struct { BodyValue *string `json:"bodyValue"` Column2 interface{} `json:"column2"` Cid *string `json:"cid"` IndexedAt time.Time `json:"indexedAt"` Uri string `json:"uri"`}
func (q *Queries) UpdateNoteAnnotation(ctx context.Context, arg UpdateNoteAnnotationParams) error { _, err := q.db.Exec(ctx, updateNoteAnnotation, arg.BodyValue, arg.Column2, arg.Cid, arg.IndexedAt, arg.Uri, ) return err}
const updateNoteBookmark = `-- name: UpdateNoteBookmark :execUPDATE notesSET target_title = NULLIF($1, ''), body_value = NULLIF($2, ''), tags_json = NULLIF($3, ''), cid = $4, indexed_at = $5WHERE uri = $6`
type UpdateNoteBookmarkParams struct { Column1 interface{} `json:"column1"` Column2 interface{} `json:"column2"` Column3 interface{} `json:"column3"` Cid *string `json:"cid"` IndexedAt time.Time `json:"indexedAt"` Uri string `json:"uri"`}
func (q *Queries) UpdateNoteBookmark(ctx context.Context, arg UpdateNoteBookmarkParams) error { _, err := q.db.Exec(ctx, updateNoteBookmark, arg.Column1, arg.Column2, arg.Column3, arg.Cid, arg.IndexedAt, arg.Uri, ) return err}
const updateNoteHighlight = `-- name: UpdateNoteHighlight :execUPDATE notesSET color = NULLIF($1, ''), tags_json = NULLIF($2, ''), cid = $3, indexed_at = $4WHERE uri = $5`
type UpdateNoteHighlightParams struct { Column1 interface{} `json:"column1"` Column2 interface{} `json:"column2"` Cid *string `json:"cid"` IndexedAt time.Time `json:"indexedAt"` Uri string `json:"uri"`}
func (q *Queries) UpdateNoteHighlight(ctx context.Context, arg UpdateNoteHighlightParams) error { _, err := q.db.Exec(ctx, updateNoteHighlight, arg.Column1, arg.Column2, arg.Cid, arg.IndexedAt, arg.Uri, ) return err}