Chinese Documentation : Order(排序)过滤器

排序过滤器指定结果是如何排序的:基于指定的属性升序 (ASC) 或者 降序 (DESC)。

REST API

基于一个属性:

filter[order]=propertyName <ASC|DESC>
Order by two or more properties: 
filter[order][0]=propertyName <ASC|DESC>&filter[order][1]propertyName]=<ASC|DESC>...
可以在REST query中使用stringified JSON format

Icon
可以在default scope中配置默认排序规则。

Node API

Icon

Methods of models in the AngularJS client have a different signature than those of the Node API. For more information, see AngularJS SDK API.

基于一个属性:

{ order: 'propertyName <ASC|DESC>' }
基于两个属性:
{ order: ['propertyName <ASC|DESC>', 'propertyName <ASC|DESC>',...] }

  • propertyName 是属性的名字。
  • <ASC|DESC> 标识是升序还是降序。

例子

基于audibleRange属性返回3个声音最大的武器:

REST
/weapons?filter[order]=audibleRange%20DESC&filter[limit]=3

基于price属性返回3个最贵的武器:

Node API
weapons.find({
 order: 'price DESC',
 limit: 3 });