Skip to content

Commit 9b062ac

Browse files
authored
Merge branch 'master' into drop-compound-index
2 parents ca0f710 + c6313cb commit 9b062ac

File tree

7 files changed

+69
-2
lines changed

7 files changed

+69
-2
lines changed

.codacy.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
exclude_paths:
2+
- '.github/**'

.github/ISSUE_TEMPLATE/BUG_REPORT.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: "Bug report"
3+
about: 'Report errors or unexpected behavior.'
4+
---
5+
6+
- Laravel-mongodb Version: #.#.#
7+
- PHP Version: #.#.#
8+
- Database Driver & Version:
9+
10+
### Description:
11+
12+
### Steps to reproduce
13+
1.
14+
2.
15+
3.
16+
17+
### Expected behaviour
18+
Tell us what should happen
19+
20+
### Actual behaviour
21+
Tell us what happens instead
22+
23+
<details><summary><b>Logs</b>:</summary>
24+
Insert log.txt here (if necessary)
25+
</details>
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea.
4+
title: "[Feature Request] "
5+
6+
---
7+
8+
### Is your feature request related to a problem?
9+
A clear and concise description of what the problem is.
10+
11+
### Describe the solution you'd like
12+
A clear and concise description of what you want to happen.
13+
14+
### Describe alternatives you've considered
15+
A clear and concise description of any alternative solutions or features you've considered.
16+
17+
### Additional context
18+
Add any other context or screenshots about the feature request here.

.github/ISSUE_TEMPLATE/QUESTION.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
name: Question
3+
about: Ask a question.
4+
title: "[Question] "
5+
labels: 'question'
6+
assignees: ''
7+
8+
---

src/Jenssegers/Mongodb/Query/Builder.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,11 @@ public function from($collection, $as = null)
700700
*/
701701
public function truncate()
702702
{
703-
$result = $this->collection->drop();
703+
$options = [
704+
'typeMap' => ['root' => 'object', 'document' => 'object'],
705+
];
706+
707+
$result = $this->collection->drop($options);
704708

705709
return (1 == (int) $result->ok);
706710
}

tests/ModelTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -572,4 +572,13 @@ public function testChunkById(): void
572572

573573
$this->assertEquals(3, $count);
574574
}
575+
576+
public function testTruncateModel()
577+
{
578+
User::create(['name' => 'John Doe']);
579+
580+
User::truncate();
581+
582+
$this->assertEquals(0, User::count());
583+
}
575584
}

tests/QueryBuilderTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ public function testDelete()
175175
public function testTruncate()
176176
{
177177
DB::collection('users')->insert(['name' => 'John Doe']);
178-
DB::collection('users')->truncate();
178+
$result = DB::collection('users')->truncate();
179+
$this->assertEquals(1, $result);
179180
$this->assertEquals(0, DB::collection('users')->count());
180181
}
181182

0 commit comments

Comments
 (0)