db.getCollection('posts').aggregate([{ $match: {"title": "some" } },
{ $unwind: "$comments" },
{ $group: {'_id': {
'year': { '$year': "$comments.createdDate" },
'month': { '$month': "$comments.createdDate" },
'day': { '$dayOfMonth': "$comments.createdDate" }
},
data: { $addToSet : "$comments" }
}},
])
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'except' =>['signup-success'],
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
];
}