Skip to content

Commit

Permalink
Merge branch 'master' into drop-compound-index
Browse files Browse the repository at this point in the history
  • Loading branch information
mnphpexpert committed Feb 8, 2020
2 parents 994656a + 9abc84c commit d4fc611
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exclude_paths:
- '.github/**'
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
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>
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE-REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
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.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/QUESTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Question
about: Ask a question.
title: "[Question] "
labels: 'question'
assignees: ''

---
6 changes: 5 additions & 1 deletion src/Jenssegers/Mongodb/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,11 @@ public function from($collection, $as = null)
*/
public function truncate()
{
$result = $this->collection->drop();
$options = [
'typeMap' => ['root' => 'object', 'document' => 'object'],
];

$result = $this->collection->drop($options);

return (1 == (int) $result->ok);
}
Expand Down
9 changes: 9 additions & 0 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,4 +572,13 @@ public function testChunkById(): void

$this->assertEquals(3, $count);
}

public function testTruncateModel()
{
User::create(['name' => 'John Doe']);

User::truncate();

$this->assertEquals(0, User::count());
}
}
3 changes: 2 additions & 1 deletion tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ public function testDelete()
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());
}

Expand Down

0 comments on commit d4fc611

Please sign in to comment.