import { query } from "./_generated/server"; import { v } from "convex/values"; export const listByChat = query({ args: { chatId: v.id("chats") }, handler: async (ctx, args) => { return await ctx.db .query("messages") .withIndex("by_chat", (q) => q.eq("chatId", args.chatId)) .order("desc") .collect(); }, });