Abdulramon JemilA

Why not `ctx.db.query("table").withIndex(vectorIndex)`?

This is just out of curiosity, why not
ctx.db.query("table").withIndex(vectorIndex)
but instead
ctx.vectorSearch()
? Is it because we don't want to expose
ctx.db
in actions?

In fact, why is there no
ctx.db.query()
in actions? Is there a reason for not allowing querying dB in actions? Seems to me like it should be fine since unlike mutations, determinism (or non-determinism) of the calling function (an action in this case) doesn't affect anything.

Concerning the first question, we can just use Typescript to narrow down the indexes in the
withIndex()
of queries and mutations to non-vector indexes, while allowing all indexes in actions.
Was this page helpful?