示例#1
0
 /**
  * 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();
 }
示例#2
0
 protected function clearCollection()
 {
     Yii::$app->mongodb->getCollection(History::collectionName())->remove();
 }