Commit 10bdd6b8 by Paul Klimov

Method "execute()" added to Mongo Database.

parent 96e794b4
...@@ -75,4 +75,15 @@ class Database extends Object ...@@ -75,4 +75,15 @@ class Database extends Object
{ {
return $this->mongoDb->createCollection($name, $options); return $this->mongoDb->createCollection($name, $options);
} }
/**
* Executes Mongo command.
* @param array $command command specification.
* @param array $options options in format: "name" => "value"
* @return array database response.
*/
public function execute($command, $options = [])
{
return $this->mongoDb->command($command, $options);
}
} }
\ No newline at end of file
...@@ -31,4 +31,16 @@ class DatabaseTest extends MongoTestCase ...@@ -31,4 +31,16 @@ class DatabaseTest extends MongoTestCase
$collectionRefreshed = $database->getCollection('customer', true); $collectionRefreshed = $database->getCollection('customer', true);
$this->assertFalse($collection === $collectionRefreshed); $this->assertFalse($collection === $collectionRefreshed);
} }
public function testCommand()
{
$database = $connection = $this->getConnection()->getDatabase();
$result = $database->execute([
'distinct' => 'customer',
'key' => 'name'
]);
$this->assertTrue(array_key_exists('ok', $result));
$this->assertTrue(array_key_exists('values', $result));
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment