MonkM
Convex Community2y ago
1 reply
Monk

inArray or sql in options?

Hello, looking for some guidance on doing a sql in with convex.

In drizzle, I am doing something like:
 const dbMatchups: Matchup[] = await db.query.matchups.findMany({
    where: and(eq(matchups.league, league), inArray(matchups.game_id, gameIds)),
  }) 


I'm not seeing a good way to do similar in convex, other than previous suggestions to query all and filter in ts.

Is there a way to do something like:
export const getMatchupsByGameIds = query({
  args: { gameIds: v.array(v.string()) },
  handler: async (ctx, { gameIds }) => {
    const matchups = await ctx.db
      .query("matchups")
      .withIndex("by_active_game_ids", (q) => q.in("game_id", gameIds))
      .take(500);
    return matchups;
  },
}); 


thanks!
Was this page helpful?