// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: profiles.sql package sqlcdb import ( "context" "time" "github.com/jackc/pgx/v5/pgtype" ) const deleteAPIKeyByURI = `-- name: DeleteAPIKeyByURI :exec DELETE FROM api_keys WHERE uri = $1 ` func (q *Queries) DeleteAPIKeyByURI(ctx context.Context, uri *string) error { _, err := q.db.Exec(ctx, deleteAPIKeyByURI, uri) return err } const deletePreferences = `-- name: DeletePreferences :exec DELETE FROM preferences WHERE uri = $1 ` func (q *Queries) DeletePreferences(ctx context.Context, uri string) error { _, err := q.db.Exec(ctx, deletePreferences, uri) return err } const deleteProfile = `-- name: DeleteProfile :exec DELETE FROM profiles WHERE uri = $1 ` func (q *Queries) DeleteProfile(ctx context.Context, uri string) error { _, err := q.db.Exec(ctx, deleteProfile, uri) return err } const getAPIKeyURIs = `-- name: GetAPIKeyURIs :many SELECT uri FROM api_keys WHERE owner_did = $1 AND uri IS NOT NULL AND uri != '' ` func (q *Queries) GetAPIKeyURIs(ctx context.Context, ownerDid string) ([]*string, error) { rows, err := q.db.Query(ctx, getAPIKeyURIs, ownerDid) 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 getPreferenceURIs = `-- name: GetPreferenceURIs :many SELECT uri FROM preferences WHERE author_did = $1 AND uri IS NOT NULL AND uri != '' ` func (q *Queries) GetPreferenceURIs(ctx context.Context, authorDid string) ([]string, error) { rows, err := q.db.Query(ctx, getPreferenceURIs, 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 getPreferences = `-- name: GetPreferences :one SELECT uri, author_did, external_link_skipped_hostnames, subscribed_labelers, label_preferences, disable_external_link_warning, enable_community_bookmarks, created_at, indexed_at, cid FROM preferences WHERE author_did = $1 ` func (q *Queries) GetPreferences(ctx context.Context, authorDid string) (Preference, error) { row := q.db.QueryRow(ctx, getPreferences, authorDid) var i Preference err := row.Scan( &i.Uri, &i.AuthorDid, &i.ExternalLinkSkippedHostnames, &i.SubscribedLabelers, &i.LabelPreferences, &i.DisableExternalLinkWarning, &i.EnableCommunityBookmarks, &i.CreatedAt, &i.IndexedAt, &i.Cid, ) return i, err } const getProfile = `-- name: GetProfile :one SELECT uri, author_did, display_name, avatar, bio, website, links_json, created_at, indexed_at FROM profiles WHERE author_did = $1 ` type GetProfileRow struct { Uri string `json:"uri"` AuthorDid string `json:"authorDid"` DisplayName *string `json:"displayName"` Avatar *string `json:"avatar"` Bio *string `json:"bio"` Website *string `json:"website"` LinksJson *string `json:"linksJson"` CreatedAt time.Time `json:"createdAt"` IndexedAt time.Time `json:"indexedAt"` } func (q *Queries) GetProfile(ctx context.Context, authorDid string) (GetProfileRow, error) { row := q.db.QueryRow(ctx, getProfile, authorDid) var i GetProfileRow err := row.Scan( &i.Uri, &i.AuthorDid, &i.DisplayName, &i.Avatar, &i.Bio, &i.Website, &i.LinksJson, &i.CreatedAt, &i.IndexedAt, ) return i, err } const getProfilesByDIDs = `-- name: GetProfilesByDIDs :many SELECT uri, author_did, display_name, bio, avatar, website, links_json, created_at, indexed_at FROM profiles WHERE author_did = ANY($1::text[]) ` type GetProfilesByDIDsRow struct { Uri string `json:"uri"` AuthorDid string `json:"authorDid"` DisplayName *string `json:"displayName"` Bio *string `json:"bio"` Avatar *string `json:"avatar"` Website *string `json:"website"` LinksJson *string `json:"linksJson"` CreatedAt time.Time `json:"createdAt"` IndexedAt time.Time `json:"indexedAt"` } func (q *Queries) GetProfilesByDIDs(ctx context.Context, dollar_1 []string) ([]GetProfilesByDIDsRow, error) { rows, err := q.db.Query(ctx, getProfilesByDIDs, dollar_1) if err != nil { return nil, err } defer rows.Close() var items []GetProfilesByDIDsRow for rows.Next() { var i GetProfilesByDIDsRow if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.DisplayName, &i.Bio, &i.Avatar, &i.Website, &i.LinksJson, &i.CreatedAt, &i.IndexedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const upsertPreferences = `-- name: UpsertPreferences :exec INSERT INTO preferences ( uri, author_did, external_link_skipped_hostnames, subscribed_labelers, label_preferences, disable_external_link_warning, enable_community_bookmarks, created_at, indexed_at, cid ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ON CONFLICT(uri) DO UPDATE SET external_link_skipped_hostnames = EXCLUDED.external_link_skipped_hostnames, subscribed_labelers = EXCLUDED.subscribed_labelers, label_preferences = EXCLUDED.label_preferences, disable_external_link_warning = EXCLUDED.disable_external_link_warning, enable_community_bookmarks = EXCLUDED.enable_community_bookmarks, indexed_at = EXCLUDED.indexed_at, cid = EXCLUDED.cid ` type UpsertPreferencesParams struct { Uri string `json:"uri"` AuthorDid string `json:"authorDid"` ExternalLinkSkippedHostnames *string `json:"externalLinkSkippedHostnames"` SubscribedLabelers *string `json:"subscribedLabelers"` LabelPreferences *string `json:"labelPreferences"` DisableExternalLinkWarning pgtype.Bool `json:"disableExternalLinkWarning"` EnableCommunityBookmarks pgtype.Bool `json:"enableCommunityBookmarks"` CreatedAt time.Time `json:"createdAt"` IndexedAt time.Time `json:"indexedAt"` Cid *string `json:"cid"` } func (q *Queries) UpsertPreferences(ctx context.Context, arg UpsertPreferencesParams) error { _, err := q.db.Exec(ctx, upsertPreferences, arg.Uri, arg.AuthorDid, arg.ExternalLinkSkippedHostnames, arg.SubscribedLabelers, arg.LabelPreferences, arg.DisableExternalLinkWarning, arg.EnableCommunityBookmarks, arg.CreatedAt, arg.IndexedAt, arg.Cid, ) return err } const upsertProfile = `-- name: UpsertProfile :exec INSERT INTO profiles (uri, author_did, display_name, avatar, bio, website, links_json, created_at, indexed_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT(uri) DO UPDATE SET display_name = EXCLUDED.display_name, avatar = EXCLUDED.avatar, bio = EXCLUDED.bio, website = EXCLUDED.website, links_json = EXCLUDED.links_json, indexed_at = EXCLUDED.indexed_at ` type UpsertProfileParams struct { Uri string `json:"uri"` AuthorDid string `json:"authorDid"` DisplayName *string `json:"displayName"` Avatar *string `json:"avatar"` Bio *string `json:"bio"` Website *string `json:"website"` LinksJson *string `json:"linksJson"` CreatedAt time.Time `json:"createdAt"` IndexedAt time.Time `json:"indexedAt"` } func (q *Queries) UpsertProfile(ctx context.Context, arg UpsertProfileParams) error { _, err := q.db.Exec(ctx, upsertProfile, arg.Uri, arg.AuthorDid, arg.DisplayName, arg.Avatar, arg.Bio, arg.Website, arg.LinksJson, arg.CreatedAt, arg.IndexedAt, ) return err }