字段名称包含空格时的猫鼬排序?

时间:2021-04-02 20:51:11

标签: javascript mongodb mongoose

我正在尝试按名称中包含空格的字段进行排序,有什么解决方法?

查询:

this.query = this.query.sort("Review Score");

型号:

["Review Score"]: {
  type: String,
},

1 个答案:

答案 0 :(得分:1)

升序:

this.query = this.query.sort({ "Review Score": 1 });

降序:

this.query = this.query.sort({ "Review Score": -1 });