// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: notes.sql package sqlcdb import ( "context" "time" ) const communityBookmarkExists = `-- name: CommunityBookmarkExists :one SELECT 1 FROM community_bookmark_refs cbr JOIN notes n ON n.uri = cbr.note_uri WHERE n.author_did = $1 AND n.target_hash = $2 LIMIT 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 :exec INSERT 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 :exec DELETE 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 :exec DELETE 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 :one SELECT 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 :one SELECT 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 FROM 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 :many SELECT 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 FROM 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 :one SELECT 1 FROM notes WHERE 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 :exec INSERT 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 :exec UPDATE notes SET body_value = $1, tags_json = NULLIF($2, ''), cid = $3, indexed_at = $4 WHERE 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 :exec UPDATE notes SET target_title = NULLIF($1, ''), body_value = NULLIF($2, ''), tags_json = NULLIF($3, ''), cid = $4, indexed_at = $5 WHERE 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 :exec UPDATE notes SET color = NULLIF($1, ''), tags_json = NULLIF($2, ''), cid = $3, indexed_at = $4 WHERE 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 }