Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ public function getDriverName()
return 'mongodb';
}

/** @inheritdoc */
public function getDriverTitle()
{
return 'MongoDB';
}

/** @inheritdoc */
protected function getDefaultPostProcessor()
{
Expand All @@ -320,6 +326,14 @@ public function setDatabase(Database $db)
$this->db = $db;
}

/** @inheritdoc */
public function threadCount()
{
$status = $this->db->command(['serverStatus' => 1])->toArray();

return $status[0]['connections']['current'];
}

/**
* Dynamically pass methods to the connection.
*
Expand Down
11 changes: 11 additions & 0 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function testConnection()
{
$connection = DB::connection('mongodb');
$this->assertInstanceOf(Connection::class, $connection);

$this->assertSame('mongodb', $connection->getDriverName());
$this->assertSame('MongoDB', $connection->getDriverTitle());
}

public function testReconnect()
Expand Down Expand Up @@ -305,4 +308,12 @@ public function testServerVersion()
$version = DB::connection('mongodb')->getServerVersion();
$this->assertIsString($version);
}

public function testThreadsCount()
{
$threads = DB::connection('mongodb')->threadCount();

$this->assertIsInt($threads);
$this->assertGreaterThanOrEqual(1, $threads);
}
}
Loading