Commit 9b062ac0 authored by Stas's avatar Stas Committed by GitHub

Merge branch 'master' into drop-compound-index

parents ca0f710a c6313cb2
exclude_paths:
- '.github/**'
---
name: "Bug report"
about: 'Report errors or unexpected behavior.'
---
- Laravel-mongodb Version: #.#.#
- PHP Version: #.#.#
- Database Driver & Version:
### Description:
### Steps to reproduce
1.
2.
3.
### Expected behaviour
Tell us what should happen
### Actual behaviour
Tell us what happens instead
<details><summary><b>Logs</b>:</summary>
Insert log.txt here (if necessary)
</details>
---
name: Feature request
about: Suggest an idea.
title: "[Feature Request] "
---
### Is your feature request related to a problem?
A clear and concise description of what the problem is.
### Describe the solution you'd like
A clear and concise description of what you want to happen.
### Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
### Additional context
Add any other context or screenshots about the feature request here.
---
name: Question
about: Ask a question.
title: "[Question] "
labels: 'question'
assignees: ''
---
......@@ -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);
}
......
......@@ -572,4 +572,13 @@ class ModelTest extends TestCase
$this->assertEquals(3, $count);
}
public function testTruncateModel()
{
User::create(['name' => 'John Doe']);
User::truncate();
$this->assertEquals(0, User::count());
}
}
......@@ -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