设置默认排序,然后使用排序方向
我想在列表加载时设置默认排序。
#COde
$sort: {
updatedAt : -1,
},
#然后我使用触发的方向触发排序
#code
...($sort ? { [`$sort[${$sort.active}]`]: $sort.direction ? 1 : -1 } : {}),
现在实际上是混合的,这是错误的。
#code
export interface QuestionFeedbackFilters {
$skip?: number;
$limit?: number;
$sort?: {
active: string;
direction: 'asc' | 'desc';
};
question?: string;
columnFilter?: ColumnFilter;
pageIndex?: number;
}
#Code
this.feedbackQuestionsService.find({
$skip,
$limit,
$sort: {
updatedAt : -1,
},
status : 1,
...resolveColumnFilters(columnFilter),
...(question ? { ['question[$like]']: question } : {}),
...($sort ? { [`$sort[${$sort.active}]`]: $sort.direction ? 1 : -1 } : {}),
})
.pipe(take(1))
.subscribe(value => {
this.store.dispatch(QuestionActions.loadListSuccess({ value }));
});