AbhishekA
Convex Community2y ago
8 replies
Abhishek

How to extract types from schema if possible ?

export const getTrendingComics = query({
  args: { id: v.string() },
  handler: async (ctx) => {
    const trendingComicsData: any = [];
    const webData = await ctx.db.query("websiteContent").first();
    const trendingComicsIdArray = webData?.trendingComics;
    if (trendingComicsIdArray) {
      await Promise.all(
        trendingComicsIdArray.map(async (id) => {
          const comic = await ctx.db.get(id);
          trendingComicsData.push(comic);
        })
      );
    }

    return trendingComicsData;
  },
});

How can I get the type of trendingComicsData from the schema ?
Was this page helpful?