3
정렬 내가몽구스 - 배열의 길이
var PostSchema = new Schema({
title: {type: String, trim: true}
, description: {type: String, trim: true}
, votes: [{ type: Schema.ObjectId, ref: 'User' }]
})
내가 투표의 즉에 따라 게시물을 정렬 할이 스키마를 데, 나는 배열의 길이를 기준으로 정렬 할 필요가있다.
은 일반적인 방법을 시도하지만,PostSchema.statics.trending = function (cb) {
return this.find().sort('votes', -1).limit(5).exec(cb)
}
어떤 도움을 작동 din't?
몽구스 사용 버전 2.7.2