We should have a query operator to cast a value to a type (at least to string or numeric.) There are situations where you need to convert two values to the same type to compare them, for example (as in this forum post) a join where one property is a number and the other a numeric string.
The SQLite syntax is CAST(expr AS type), where type is a SQL column type, as in this list. The resulting affinity will be text, numeric, integer, real, or blob. I suggest we make our JSON syntax ["CAST", type, value] where type is an affinity name as a string literal.
There are some workarounds, that use operators that typecast their operands:
(x + 0) will convert x to a number
(x || '') will convert x to a string