Skip to main content

getCard

Retrieves a single card by ID with all associated metadata and file URLs.
import { useQuery } from "convex/react";
import { api } from "@teak/convex";

function CardDetail({ cardId }: { cardId: Id<"cards"> }) {
  const card = useQuery(api.card.getCard.getCard, { id: cardId });

  if (!card) return <div>Card not found</div>;

  return (
    <div>
      <h1>{card.content}</h1>
      {card.fileUrl && <img src={card.fileUrl} />}
      {card.thumbnailUrl && <img src={card.thumbnailUrl} />}
      <p>Tags: {card.tags?.join(", ")}</p>
    </div>
  );
}

Arguments

id
Id<'cards'>
required
The unique identifier of the card to retrieve.

Returns

card
Card | null
Returns the card object with all fields and generated file URLs, or null if:
  • Card doesn’t exist
  • User is not authenticated
  • User doesn’t own the card (authorization check)

getCards

Retrieves a filtered list of cards with optional type and favorites filtering.
import { useQuery } from "convex/react";
import { api } from "@teak/convex";

function CardList() {
  const cards = useQuery(api.card.getCards.getCards, {
    type: "link",
    favoritesOnly: false,
    limit: 50
  });

  return (
    <div>
      {cards?.map(card => (
        <CardItem key={card._id} card={card} />
      ))}
    </div>
  );
}

Arguments

type
CardType
Filter cards by type. If omitted, returns all types.Values: text | link | image | video | audio | document | palette | quote
favoritesOnly
boolean
default:false
If true, returns only cards marked as favorites.
limit
number
default:50
Maximum number of cards to return. Cards are returned in descending creation order (newest first).

Returns

cards
Card[]
Array of card objects matching the filter criteria. Returns empty array if:
  • User is not authenticated
  • No cards match the filters
Each card includes all fields from getCard response, including auto-generated file URLs.

Behavior

Uses compound indexes to avoid post-query filtering:
  • Type filter: Uses by_user_type_deleted index
  • Favorites filter: Uses by_user_favorites_deleted index
  • No filters: Uses by_user_deleted index
All queries exclude deleted cards by default (isDeleted: undefined).
Generates temporary signed URLs for:
  • fileUrl - Main file (if fileId exists)
  • thumbnailUrl - Thumbnail image (if thumbnailId exists)
  • screenshotUrl - Link preview screenshot (if stored)
  • linkPreviewImageUrl - Link preview image (if stored)
URLs are generated via ctx.storage.getUrl() and expire after a period.
Applies display formatting to quote cards via applyQuoteFormattingToList():
  • Restores quotation marks for display
  • Preserves original normalized content in database

getDeletedCards

Retrieves soft-deleted cards (trash/recycle bin).
import { useQuery } from "convex/react";
import { api } from "@teak/convex";

function TrashBin() {
  const deletedCards = useQuery(api.card.getCard.getDeletedCards, {
    limit: 50
  });

  return (
    <div>
      <h2>Trash ({deletedCards?.length})</h2>
      {deletedCards?.map(card => (
        <DeletedCardItem key={card._id} card={card} />
      ))}
    </div>
  );
}

Arguments

limit
number
default:50
Maximum number of deleted cards to return. Ordered by deletion date (newest first).

Returns

deletedCards
Card[]
Array of soft-deleted cards. Returns empty array if user is not authenticated or no deleted cards exist.

Source References

  • getCard: packages/convex/card/getCard.ts:20
  • getCards: packages/convex/card/getCards.ts:45
  • getDeletedCards: packages/convex/card/getCard.ts:60

Build docs developers (and LLMs) love