私はこのコレクションを持っています:
{
"_id" : ObjectId("522f05f06f92046814003b84"),
"personal_id" : "0609150071",
"superstructure_id" : 1,
"name" : "David",
"surname" : "Bar",
"plays_often" : 1,
...
"created" : ISODate("2013-09-10T13:43:38Z")
}
{
"_id" : ObjectId("522f05f06f92046814003b84"),
"personal_id" : "0609150071",
"superstructure_id" : 1,
"name" : "David",
"surname" : "Bar",
"plays_often" : 1,
...
"created" : ISODate("2013-09-10T14:11:55Z")
}
...
次のレコードを検索する必要があります。
基準:
superstructure_id: 1
でグループ化
personal_id
created
これらのグループから、フィールドに基づいて最新のレコードのみを返します次に、すべてのグループ結果を並べ替えます
plays_often
制限付き 5
"personal_id" : "0609150071"
そのため、新しい日時が にあるため、結果には次のレコードのみが含まれcreated
ます:
{
"_id" : ObjectId("522f05f06f92046814003b84"),
"personal_id" : "0609150071",
"superstructure_id" : 1,
"name" : "David",
"surname" : "Bar",
"plays_often" : 1,
...
"created" : ISODate("2013-09-10T14:11:55Z")
}
これはmongodbで可能ですか?