mercyM
Convex Community3mo ago
2 replies
mercy

Filtering with Queries or with TS?

What is the preferred approach to filtering (for example filtering on tenant id or on soft deletes) .

In this case the _id of the document is provided but additional checks need to be done.

Is it using regular
ctx.db.get
and then doing the filtering in TypeScript

Or

Is it creating a index on the to be filtered table and then doing the filtering with
withIndex
and
unique
with a falsy check?

My thoughts:
Using the TypeScript approach gives the developer more fine grained control on handling the exact error case and adding logging and meaningful responses to the client. It does add boilerplate though.

Using the query approach seems to be easier when it comes to adding new constraints to a request and it seems to have less boilerplate.

I would like your thoughts on this and on how you handle these cases.
Was this page helpful?