Commit 9442df10 authored by Ditty's avatar Ditty

Fix truncate on models

According to docs array or object might be returned, so we need to add options. See https://docs.mongodb.com/php-library/v1.5/reference/method/MongoDBCollection-drop/
parent ef147ea5
......@@ -700,7 +700,11 @@ class Builder extends BaseBuilder
*/
public function truncate()
{
$result = $this->collection->drop();
$options = [
'typeMap' => ['root' => 'object', 'document' => 'object'],
];
$result = $this->collection->drop($options);
return (1 == (int) $result->ok);
}
......
......@@ -175,7 +175,8 @@ class QueryBuilderTest extends TestCase
public function testTruncate()
{
DB::collection('users')->insert(['name' => 'John Doe']);
DB::collection('users')->truncate();
$result = DB::collection('users')->truncate();
$this->assertEquals(1, $result);
$this->assertEquals(0, DB::collection('users')->count());
}
......
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