0
我想從mongo控制檯中使用mongo-odm重現以下工作查詢。與DBref和Mongo-ODM一起使用集合
db.Record.aggregate([ {$match: {member: DBRef("Member", ObjectId("556e5dbfa10fdb0ddc0041c5"), "doctrine_odm")}}, {$sort: {timestamp: -1}}, {$group : {_id : "$details.type", firstRecord: {$first: "$_id"}}} ])
樣本記錄是
{
"_id" : ObjectId("556e5dbfa10fdb0ddc0041c8"),
"member" : DBRef("Member", ObjectId("556e5dbfa10fdb0ddc0041c5"), "doctrine_odm"),
"timestamp" : ISODate("2015-06-03T01:51:59Z"),
"details" : [
{
"accountNumber" : "101",
"type" : "premium"
}
]
}
我試過多種格式以及最新的 - 仍然沒有工作 - 就是這樣
$collection = $dm->getDocumentCollection('Record');
$pipeline = array(
array(
'$match' => array(
"member" => \MongoDBRef::create("Member", "556e5dbfa10fdb0ddc0041c5", "doctrine_odm")
)
),
);
$results = $collection->aggregate($pipeline);
感謝。