/** * Load user chat history * * @access public * @param mixed $chatId * @param integer $limit * @return array */ public function getHistory($chatId, $limit = 10) { $query = new Query(); $query->select(['user_id', 'username', 'message', 'timestamp', 'avatar_16', 'avatar_32'])->from(History::collectionName())->where(['chat_id' => $chatId]); if ($limit) { $query->limit($limit); } return $query->all(); }
protected function clearCollection() { Yii::$app->mongodb->getCollection(History::collectionName())->remove(); }