Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is no single right answer to this question. The optimal solution chiefly depends on what percentage of your entities are likely going to be in deleted state at any given time.</p> <p>One option is to store a field like <code>@Index(IfTrue.class) boolean active;</code> and add this filter to all queries:</p> <pre><code>ofy.load().type(Thing.class).filter("size &gt;", 20).filter("active", true) </code></pre> <p>The downside of this is that it requires adding extra indexes - possibly several because you may now need multi-property indexes where single-property indexes would have sufficed.</p> <p>Alternatively, you can store a 'deleted' flag and manually exclude deleted entities from query results. Less indexes to maintain, but it adds extra overhead to each query as you pull back records you don't want. If your deleted entries are sparse, this won't matter.</p> <p>One last trick. You might find it best to store index a deleted date since it's probably most useful: <code>@Index Date deleted;</code> This lets you <code>filter("deleted", null)</code> to get the active items and also lets you filter by datestamp to get really old entities that you may wish to purge. However, be aware that this will cause the deleted date to index into any multi-property indexes, possibly significantly increasing index size if you have a high percentage of deleted entities. In this case, you may wish to <code>@Index(IfNull.class) Date deleted;</code> and use map-reduce to purge sufficiently old entities.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload