【发布时间】:2011-11-21 02:54:57
【问题描述】:
我想为主题实现“碰撞”功能。一旦一个主题被碰撞,它将有一个新的“bump_date”字段。我想对其进行排序,以便当有“bump_date”字段时,它会像“created”字段一样进行排序。这是我的 db.topics 的示例:
{
"text" : "test 1",
"created" : "Sun Nov 20 2011 02:03:28 GMT-0800 (PST)"
},
{
"text" : "test 2",
"created" : "Sun Nov 18 2011 02:03:28 GMT-0800 (PST)"
},
{
"text" : "test 3",
"created" : "Sun Nov 17 2011 02:03:28 GMT-0800 (PST)",
"bump_date: : "Sun Nov 19 2011 02:03:28 GMT-0800 (PST)"
}
我希望排序按“test 1”、“test 3”、“test 2”的顺序返回
【问题讨论】:
-
这可能有助于 MongoDB 排序code-sample.com/2016/07/mongodb-sort-by-date.html
标签: mongodb