My Sample collection:
{
"_id" : ObjectId("58dbc09b19d7a17e44201982"),
"process_id" : "2-1490770330177",
"contacts" : [
{
"party_id" : 6636,
"completed" : true,
"kind" : 1
},
{
"party_id" : 139611,
"completed" : true,
"kind" : 1
},
{
"party_id" : 32609,
"completed" : true,
"kind" : 1
},
{
"party_id" : 49520,
"completed" : false,
"kind" : 1
},
{
"party_id" : 204031,
"completed" : false,
"kind" : 1
},
{
"party_id" : 204379,
"completed" : false,
"kind" : 1
}
],
"tags" : [
1277
]
}
And When I test this document with RoboMongo via followig query:
db.getCollection('BatchTag').aggregate(
{'$match':{"process_id":'2-1490770330177'}},
{'$unwind':'$contacts'},
{'$match':{'contacts.completed':false}},
{'$group':{_id:'$_id','contacts':{'$push':'$contacts'}}}
)
I've received this result.
{
"_id" : ObjectId("58dbc09b19d7a17e44201982"),
"contacts" : [
{
"party_id" : 49520,
"completed" : false,
"kind" : 1
},
{
"party_id" : 204031,
"completed" : false,
"kind" : 1
},
{
"party_id" : 204379,
"completed" : false,
"kind" : 1
}
]
}
Bu When I execute some query on PHP. I've received "Failed to decode document from the server." exception. My PHP code is here:
$command = new Command([
"aggregate"=>"BatchTag",
"pipeline" => [
['$match'=>["process_id"=>$processUID]],
['$unwind'=>'$contacts'],
['$match'=>['contacts.completed'=>false]],
['$group'=>['_id'=>'$_id','contacts'=>['$push'=>'$contacts']]]
]
]);
$rows = $this->getMongoManager()->executeCommand($this->container->getParameter("mongodb_db_name").".BatchTag",$command)->toArray();
I don't understand, what is wrong!