Reputation: 12846
I am using Laravel MongoDB library (formerly know as Laravel Jenssegers MongoDB library).
This is my employees collection
{
_id : {$oid: 2ndkj3720eA83b24},
name : 'Employee1',
status : 'a',
deleted_at : null
}
This is my task collection:-
{
_id : {$oid: 893jfo2ok01398190},
name : 'Task 1',
employees : [
{$oid: ae2nvg6788eA83b24},
{$oid: be09gh56701398190},
{$oid: bf0e28bfi45202bc0}
],
complete_status : 'c',
status : 'a',
deleted_at : null
}
The employees column in task collection is an array of object ids of employees.
This is how I fetch employee list:-
$aggergateCondition = array(
array(
'$lookup' => array(
'as' => 'taskList',
'from' => 'tasks',
'foreignField' => 'volunteers',
'localField' => '_id'
)
)
);
$employeeListing = Employee::raw(function($collection) use($aggergateCondition){
return $collection->aggregate($aggergateCondition);
});
But now I want to fetch only those tasks whose complete_status is 'c'.
How can I do that?
Upvotes: 0
Views: 22