0
我开发MEAN堆栈应用的MongoDB排序查询涉及多种类型的媒体(如照片,视频,Web内容快照)和文本。上收集数据
我需要通过对特定字段应用排序查询来按特定顺序排序我的集合。
排序:
- 0:Text, 1:Photo, 2:Video, 3:Web-content-snapshot
- 1:Photo, 2:Video, 3:Web-content-snapshot, 0:Text
- 2:Video, 1:Photo, 3:Web-content-snapshot, 0:Text
- 3:Web-content-snapshot, 2:Video, 1: Photo, 0:Text
收藏:
var mediaSchema = new Schema({
user_id: {type: Schema.Types.ObjectId,ref: 'User'},
// media description
description: {type: String},
// Media type: 1: image, 2: video, 3: Web content snapshot, 0: Text
media_type: {type: Number,default: 0,index: true},
media_name: {type: String},
snapshot_url: {type: String},
snapshot_content: {type: String},
Text: {type: String}
},
{collection: 'media'});
请指导我如何申请上的媒体类型排序的查询,所以我可以在上述媒体类型的描述订购。我使用的猫鼬模块MongoDB的查询。