Every model type has a natural / default ordering field and direction.
Universal, Content, and User Profile types order by their
created timestamp, ascending from oldest to newest.
The Event type orders by its
created timestamp, descending from newest to oldest.
The natural ordering of query results may be reversed using
desc() query methods.
The Universal type supports custom ordering for the following field types:
To specify custom natural ordering on one of these field types use the
order attribute set to
highScore: type: integer order: true
If a model is a child within a container, then the field names which allow custom ordering are limited to
The hierarchy field type provides custom, manual ordering of the Universal type. When specified on a Universal model, it automatically changes the natural ordering to use this field.
Hierarchy values may be thought of as a numerical value, however for simplicity it's best to use them in relationship to other hierarchy values, and other models that already exist.
For example, given 3 existing Tasks, moving 1 of those Tasks between two others:
/** * Set 'moveTask' hierarchy value to a position between 'afterTask' and 'beforeTask' */ moveTask.hierarchy = afterTask.hierarchy.before(beforeTask.hierarchy);
The "tasks" example shows basic reordering functionality using a hierarchy field.