简体   繁体   中英

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:

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

For ascending:

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

For descending:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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