Hmza
Hmza7mo ago

`Many documents read in a single

Many documents read in a single function execution (actual: 14837, limit: 16384). Consider using smaller limits in your queries, paginating your queries, or using indexed queries with a selective index range expressions.
1 Reply
Hmza
HmzaOP7mo ago
If i have to read lets say a 1000 documents for a user and show it in a datatable. How should i be dividing that? It becomes neccasary here to use paginated query then or is there any other way? I'm writing a CRM and what i'm trying todo is to get all "Leads" + "Client info" + "Tasks" they have in a query. How should i be handling that? const filteredLeads = allLeads.filter((lead) => staffIds.includes(lead.assignedStaff)); const leadsWithClientandTaskInfo = await Promise.all( filteredLeads.map(async (lead) => { const client = await ctx.db.get(lead.client); const tasks = await ctx.db.query("leadTask").filter((q) => q.eq(q.field("lead"), lead._id)).order("desc").collect(); return { ...lead, client, tasks } as LeadWithClientAndTask; }) ); types type Lead = Doc<"leads">; type Client = Doc<"clients">; type TaskWithClient = Doc<"leadTask"> & { clientId: string }; type LeadWithClientAndTask = Lead & { client: Client; tasks: TaskWithClient[] };

Did you find this page helpful?