SorinS
Convex Community7mo ago
5 replies
Sorin

Billing question regarding counting function calls....

Hi guys, I have a little question regarding what is counted as function call. This would influence how I design a few things in my app

Question 1: if I call queries or mutations from the FE, they are counted towoards the function calls. correct? (thi is more or less a sanity check)

....
Lets assume I have the following:

query: getTodo (id:string)
- this will get a dodo from db

query: getMultipleTodos(ids: string[])
- return ids.map(id => cts.runQuery(getTodo(id))

basically, getMultipleTodos will call getTodo multiple times, but this is in the convex folder, in the query def.

case 1: if I iterate over the todo ids in FE and I call getTodo for each one (N times) => this si counted as N function calls?

case2: I call getMultipleTodos from FE. This will generate multiple queries in the "be". Is this counted as 1 function call or as N+1 calls?

I am asking because this would affect the way code is shared in the BE, because I can extract the ctx.db.get from the getTodo and reuse it in both getTodo and getMultipleTodos in order to avoid hitting cts.runQuery

Thanks
Was this page helpful?