StatUserModel.php 749 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Model\Mongo;
  4. use Hyperf\Mongodb\Mongodb;
  5. use Hyperf\Utils\ApplicationContext;
  6. use MongoDB\Client;
  7. /**
  8. * Class CrashLogModel
  9. * @return Client|StatUserModel
  10. *
  11. * @package App\Model\Mongo
  12. */
  13. class StatUserModel extends Mongodb
  14. {
  15. // mongoDB 表名
  16. // protected $dbName = 'douyin_lite'; // mongoDB 库名
  17. protected $collectionName = 'stat_user'; // mongoDB 表名
  18. public function db()
  19. {
  20. $container = ApplicationContext::getContainer();
  21. /**
  22. * @var $mongodb Client
  23. */
  24. $mongodb = $container->get(self::class);
  25. return $mongodb->selectDatabase(env('MONGODB_DB'))
  26. ->selectCollection($this->collectionName);
  27. }
  28. }