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
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
withIndex
and
unique
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.