【发布时间】:2018-09-28 23:01:00
【问题描述】:
我想按特定字符串属性的长度对查找结果进行排序。我的架构有一个子属性“评论”,我想按评论的长度排序。 我正在运行类似这样的查找查询。
Model.find(query, callback)
.sort({ 'review.comment.length' : -1 })
架构:
feedback = new Schema({
review: {type: content}
})
content = new Schema({
comment: {type: String},
date: {type: Date}
})
但这不起作用。有人可以帮助进行正确的查询吗?
【问题讨论】:
-
你能分享你的架构吗?
-
@GeorgeBailey 添加了架构的相关部分。
标签: javascript node.js mongodb mongoose