// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: bookmarks.sql package sqlcdb import ( "context" "time" ) const createBookmark = `-- name: CreateBookmark :exec INSERT INTO bookmarks (uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ON CONFLICT(uri) DO UPDATE SET source = EXCLUDED.source, source_hash = EXCLUDED.source_hash, title = EXCLUDED.title, description = EXCLUDED.description, tags_json = EXCLUDED.tags_json, indexed_at = EXCLUDED.indexed_at, cid = EXCLUDED.cid ` type CreateBookmarkParams struct { Uri string `json:"uri"` AuthorDid string `json:"authorDid"` Source string `json:"source"` SourceHash string `json:"sourceHash"` Title *string `json:"title"` Description *string `json:"description"` TagsJson *string `json:"tagsJson"` CreatedAt time.Time `json:"createdAt"` IndexedAt time.Time `json:"indexedAt"` Cid *string `json:"cid"` } func (q *Queries) CreateBookmark(ctx context.Context, arg CreateBookmarkParams) error { _, err := q.db.Exec(ctx, createBookmark, arg.Uri, arg.AuthorDid, arg.Source, arg.SourceHash, arg.Title, arg.Description, arg.TagsJson, arg.CreatedAt, arg.IndexedAt, arg.Cid, ) return err } const deleteBookmark = `-- name: DeleteBookmark :exec DELETE FROM bookmarks WHERE uri = $1 ` func (q *Queries) DeleteBookmark(ctx context.Context, uri string) error { _, err := q.db.Exec(ctx, deleteBookmark, uri) return err } const getBookmarkByURI = `-- name: GetBookmarkByURI :one SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE uri = $1 ` func (q *Queries) GetBookmarkByURI(ctx context.Context, uri string) (AllBookmark, error) { row := q.db.QueryRow(ctx, getBookmarkByURI, uri) var i AllBookmark err := row.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &i.TagsJson, &i.CreatedAt, &i.IndexedAt, &i.Cid, ) return i, err } const getBookmarkURIs = `-- name: GetBookmarkURIs :many SELECT uri FROM all_bookmarks WHERE author_did = $1 ` func (q *Queries) GetBookmarkURIs(ctx context.Context, authorDid string) ([]string, error) { rows, err := q.db.Query(ctx, getBookmarkURIs, 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 getBookmarksByAuthor = `-- name: GetBookmarksByAuthor :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE author_did = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetBookmarksByAuthorParams struct { AuthorDid string `json:"authorDid"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetBookmarksByAuthor(ctx context.Context, arg GetBookmarksByAuthorParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getBookmarksByAuthor, arg.AuthorDid, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getBookmarksByTag = `-- name: GetBookmarksByTag :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE lower(tags_json)::jsonb ? $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetBookmarksByTagParams struct { TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetBookmarksByTag(ctx context.Context, arg GetBookmarksByTagParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getBookmarksByTag, arg.TagsJson, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getBookmarksByTagAndAuthor = `-- name: GetBookmarksByTagAndAuthor :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE author_did = $1 AND lower(tags_json)::jsonb ? $2 ORDER BY created_at DESC LIMIT $3 OFFSET $4 ` type GetBookmarksByTagAndAuthorParams struct { AuthorDid string `json:"authorDid"` TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetBookmarksByTagAndAuthor(ctx context.Context, arg GetBookmarksByTagAndAuthorParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getBookmarksByTagAndAuthor, arg.AuthorDid, arg.TagsJson, arg.Limit, arg.Offset, ) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getBookmarksByTargetHash = `-- name: GetBookmarksByTargetHash :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE source_hash = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetBookmarksByTargetHashParams struct { SourceHash string `json:"sourceHash"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetBookmarksByTargetHash(ctx context.Context, arg GetBookmarksByTargetHashParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getBookmarksByTargetHash, arg.SourceHash, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getBookmarksByURIs = `-- name: GetBookmarksByURIs :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE uri = ANY($1::text[]) ` func (q *Queries) GetBookmarksByURIs(ctx context.Context, dollar_1 []string) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getBookmarksByURIs, dollar_1) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getMarginBookmarks = `-- name: GetMarginBookmarks :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE uri NOT LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $1 OFFSET $2 ` type GetMarginBookmarksParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetMarginBookmarks(ctx context.Context, arg GetMarginBookmarksParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getMarginBookmarks, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getMarginBookmarksByAuthor = `-- name: GetMarginBookmarksByAuthor :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE author_did = $1 AND uri NOT LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetMarginBookmarksByAuthorParams struct { AuthorDid string `json:"authorDid"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetMarginBookmarksByAuthor(ctx context.Context, arg GetMarginBookmarksByAuthorParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getMarginBookmarksByAuthor, arg.AuthorDid, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getMarginBookmarksByTag = `-- name: GetMarginBookmarksByTag :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE lower(tags_json)::jsonb ? $1 AND uri NOT LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetMarginBookmarksByTagParams struct { TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetMarginBookmarksByTag(ctx context.Context, arg GetMarginBookmarksByTagParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getMarginBookmarksByTag, arg.TagsJson, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getMarginBookmarksByTagAndAuthor = `-- name: GetMarginBookmarksByTagAndAuthor :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE author_did = $1 AND lower(tags_json)::jsonb ? $2 AND uri NOT LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $3 OFFSET $4 ` type GetMarginBookmarksByTagAndAuthorParams struct { AuthorDid string `json:"authorDid"` TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetMarginBookmarksByTagAndAuthor(ctx context.Context, arg GetMarginBookmarksByTagAndAuthorParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getMarginBookmarksByTagAndAuthor, arg.AuthorDid, arg.TagsJson, arg.Limit, arg.Offset, ) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getPopularBookmarks = `-- name: GetPopularBookmarks :many SELECT b.uri, b.author_did, b.source, b.source_hash, b.title, b.description, b.tags_json, b.created_at, b.indexed_at, b.cid FROM all_bookmarks b LEFT JOIN LATERAL ( SELECT COUNT(*) as cnt FROM likes WHERE subject_uri = b.uri ) l ON true LEFT JOIN LATERAL ( SELECT COUNT(*) as cnt FROM replies WHERE root_uri = b.uri ) r ON true WHERE b.created_at > $1 AND (l.cnt + r.cnt) > 0 ORDER BY (l.cnt + r.cnt) DESC, b.created_at DESC LIMIT $2 OFFSET $3 ` type GetPopularBookmarksParams struct { CreatedAt time.Time `json:"createdAt"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetPopularBookmarks(ctx context.Context, arg GetPopularBookmarksParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getPopularBookmarks, arg.CreatedAt, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getRecentBookmarks = `-- name: GetRecentBookmarks :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks ORDER BY created_at DESC LIMIT $1 OFFSET $2 ` type GetRecentBookmarksParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetRecentBookmarks(ctx context.Context, arg GetRecentBookmarksParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getRecentBookmarks, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getSembleBookmarks = `-- name: GetSembleBookmarks :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE uri LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $1 OFFSET $2 ` type GetSembleBookmarksParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetSembleBookmarks(ctx context.Context, arg GetSembleBookmarksParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getSembleBookmarks, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getSembleBookmarksByAuthor = `-- name: GetSembleBookmarksByAuthor :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE author_did = $1 AND uri LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetSembleBookmarksByAuthorParams struct { AuthorDid string `json:"authorDid"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetSembleBookmarksByAuthor(ctx context.Context, arg GetSembleBookmarksByAuthorParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getSembleBookmarksByAuthor, arg.AuthorDid, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getSembleBookmarksByTag = `-- name: GetSembleBookmarksByTag :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE lower(tags_json)::jsonb ? $1 AND uri LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetSembleBookmarksByTagParams struct { TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetSembleBookmarksByTag(ctx context.Context, arg GetSembleBookmarksByTagParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getSembleBookmarksByTag, arg.TagsJson, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getSembleBookmarksByTagAndAuthor = `-- name: GetSembleBookmarksByTagAndAuthor :many SELECT uri, author_did, source, source_hash, title, description, tags_json, created_at, indexed_at, cid FROM all_bookmarks WHERE author_did = $1 AND lower(tags_json)::jsonb ? $2 AND uri LIKE '%network.cosmik%' ORDER BY created_at DESC LIMIT $3 OFFSET $4 ` type GetSembleBookmarksByTagAndAuthorParams struct { AuthorDid string `json:"authorDid"` TagsJson *string `json:"tagsJson"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetSembleBookmarksByTagAndAuthor(ctx context.Context, arg GetSembleBookmarksByTagAndAuthorParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getSembleBookmarksByTagAndAuthor, arg.AuthorDid, arg.TagsJson, arg.Limit, arg.Offset, ) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 getShelvedBookmarks = `-- name: GetShelvedBookmarks :many SELECT b.uri, b.author_did, b.source, b.source_hash, b.title, b.description, b.tags_json, b.created_at, b.indexed_at, b.cid FROM all_bookmarks b WHERE b.created_at < $1 AND b.created_at > $2 AND NOT EXISTS (SELECT 1 FROM likes WHERE subject_uri = b.uri) AND NOT EXISTS (SELECT 1 FROM replies WHERE root_uri = b.uri) ORDER BY RANDOM() LIMIT $3 OFFSET $4 ` type GetShelvedBookmarksParams struct { CreatedAt time.Time `json:"createdAt"` CreatedAt_2 time.Time `json:"createdAt2"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetShelvedBookmarks(ctx context.Context, arg GetShelvedBookmarksParams) ([]AllBookmark, error) { rows, err := q.db.Query(ctx, getShelvedBookmarks, arg.CreatedAt, arg.CreatedAt_2, arg.Limit, arg.Offset, ) if err != nil { return nil, err } defer rows.Close() var items []AllBookmark for rows.Next() { var i AllBookmark if err := rows.Scan( &i.Uri, &i.AuthorDid, &i.Source, &i.SourceHash, &i.Title, &i.Description, &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 updateBookmark = `-- name: UpdateBookmark :exec UPDATE bookmarks SET title = $1, description = $2, tags_json = $3, cid = $4, indexed_at = $5 WHERE uri = $6 ` type UpdateBookmarkParams struct { Title *string `json:"title"` Description *string `json:"description"` TagsJson *string `json:"tagsJson"` Cid *string `json:"cid"` IndexedAt time.Time `json:"indexedAt"` Uri string `json:"uri"` } func (q *Queries) UpdateBookmark(ctx context.Context, arg UpdateBookmarkParams) error { _, err := q.db.Exec(ctx, updateBookmark, arg.Title, arg.Description, arg.TagsJson, arg.Cid, arg.IndexedAt, arg.Uri, ) return err }