Shapes
A computed field in a shape gets calculated for every object
on which it is defined, not just the ones that make it
through the filter, but every one. The filter may, in
fact, refer to a computed value, so it must be known
for all objects. This may be inefficient in some cases,
such as the previous example with fetching the posts
with their length and a comparison to average post
length. You can use a with
block to factor out some
common computations, give them names and use them later
on in a query. Let's re-write our inefficient query like
this:
The with
block is also very convenient if you need to
compare objects in a set to other objects in the same
set, such as "find all movies that have the same title".
The with
block makes it easy to define a copy of the
original set to be used later in comparisons. Try this
out: