MongoDB中的自定义排序

时间:2015-09-25 02:16:06

标签: mongodb mongodb-query aggregation-framework

我有以下内容,我想首先将其状态为FORSALE,第二名为OPENED,最后为CLOSEDFORSALEOPENED的各方必须从最新到最晚的订购。必须从最旧的(CLOSED字段)订购start_time的各方。

任何线索如何使用MongoDB构建查询?

{
    "id": "608",
    "facebook_event_id": "840660989387123",
    "title": "Direito à Fantasia - Save The Date",
    "hot": false,
    "admission": null,
    "local": "Prime Hall",
    "start_time": "2015-11-13T23:11:00-0500",
    "college": {
    "name": "Pontifícia Universidade Católica De Campinas",
    "initials": "PUCCAMP"
},
    "status": "FORSALE",
    "fee": "10",
    "attending": {
    "men": null,
    "women": null,
    "total": null,
    "media": null
},
    "images": {
        "cover": "cover608.gif",
        "detail": "detail608.gif"
    }
 },
{
    "id": "600",
    "facebook_event_id": "925972197477371",
    "title": "Cam Rodeo Festival 2015",
    "hot": false,
    "admission": null,
    "local": "Barroca Zona Sul",
    "start_time": "2015-11-13T22:11:00-0500",
    "college": {
        "name": "Universidade De São Paulo",
        "initials": "USP"
    },
    "status": "OPENED",
    "fee": "10",
    "attending": {
        "men": null,
        "women": null,
        "total": null,
        "media": null
    },
    "images": {
        "cover": "cover600.gif",
        "detail": "detail600.gif"
    }
},
{
    "id": "588",
    "facebook_event_id": "1651374941773874",
    "title": "Sabóia 2 ",
    "hot": false,
    "admission": null,
    "local": "Espaço Anchieta.",
    "start_time": "2015-11-07T23:11:00-0500",
    "college": {
        "name": "Faculdade De Engenharia Industrial",
        "initials": "FEI"
    },
    "status": "OPENED",
    "fee": "10",
    "attending": {
        "men": null,
        "women": null,
        "total": null,
        "media": null
    },
    "images": {
        "cover": "cover588.gif",
        "detail": "detail588.gif"
    }
}

0 个答案:

没有答案