简体   繁体   English

Mongoose 排序时字段名称包含空格?

[英]Mongoose sort when field name contains whitespace?

I am trying to sort by a field with whitespace in the name, what is the workaround for this?我正在尝试按名称中带有空格的字段进行排序,解决方法是什么?

Query:询问:

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

Model: Model:

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

For ascending:对于上升:

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

For descending:对于下降:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM