我正在尝试对相关模型的属性进行排序,但无法使其正常工作。
我正在加载一张交货时刻表,并想对postal_code进行排序,而postal_code是相关模型“ postalcode”的属性
这是我的交货时刻模型:
{
"name": "delivery_moment",
"plural": "delivery-moments",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true,
"mysql": {
"schema": "LOOPBACK",
"table": "table_delivery_moment"
}
},
"mixins": {
"TimeStamp": {
"createdAt": "created",
"updatedAt": "updated",
"required": false,
"validateUpsert": true,
"silenceWarnings": false
}
},
"properties": {
"created": {
"type": "date",
"required": false
}
},
"validations": [],
"relations": {
"distributor": {
"type": "belongsTo",
"model": "distributor",
"foreignKey": "distributor_id"
},
"delivery_times": {
"type": "hasAndBelongsToMany",
"model": "delivery_time",
"as": "delivery_moment_id",
"foreignKey": "delivery_time_id",
"throughTable": "delivery_moment_delivery_time"
},
"postalcode": {
"type": "belongsTo",
"model": "postalcode",
"foreignKey": "postal_code_id"
}
},
"acls": [],
"methods": {}
}
这是我的邮政编码模型:
{
"name": "postalcode",
"plural": "postalcodes",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true,
"mysql": {
"schema": "LOOPBACK",
"table": "table_postalcode"
}
},
"properties": {
"postal_code": {
"type": "number",
"required": false,
"dataType": "integer"
},
"catering_area": {
"type": "boolean",
"required": false
},
"created": {
"type": "date",
"required": false
}
},
"validations": [],
"relations": {
"delivery_moments": {
"type": "hasMany",
"model": "delivery_moments",
"foreignKey": "postal_code_id"
},
"depot": {
"type": "belongsTo",
"model": "depot",
"foreignKey": "hub_id"
},
"current_routes": {
"type": "hasAndBelongsToMany",
"model": "current_route",
"as": "postalCodeId",
"foreignKey": "currentRouteId",
"throughTable": "table_postalcode_currentroute"
}
},
"acls": [],
"methods": {}
}
这是我要执行的查询:
?filter[include][0]=postalcode&filter[include][1]=distributor&filter[include][2]=delivery_times&filter[order]=postalcode.postal_code ASC
我尝试了多种变化,例如:
filter[order][postalcode]=postal_code ASC
但不对结果进行排序。如何获得理想的结果?