Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
laravel-mongodb
Commits
e5d0dd71
Commit
e5d0dd71
authored
Feb 09, 2020
by
Ditty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add collection info and tests
parent
40058c75
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
Builder.php
src/Jenssegers/Mongodb/Schema/Builder.php
+4
-3
SchemaTest.php
tests/SchemaTest.php
+4
-0
No files found.
src/Jenssegers/Mongodb/Schema/Builder.php
View file @
e5d0dd71
...
...
@@ -34,15 +34,16 @@ class Builder extends \Illuminate\Database\Schema\Builder
/**
* Determine if the given collection exists.
* @param string $collection
* @return bool
* @param bool $collection_info
* @return bool|\MongoDB\Model\CollectionInfo
*/
public
function
hasCollection
(
$collection
)
public
function
hasCollection
(
$collection
,
$collection_info
=
false
)
{
$db
=
$this
->
connection
->
getMongoDB
();
foreach
(
$db
->
listCollections
()
as
$collectionFromMongo
)
{
if
(
$collectionFromMongo
->
getName
()
==
$collection
)
{
return
true
;
return
$collection_info
?
$collectionFromMongo
:
true
;
}
}
...
...
tests/SchemaTest.php
View file @
e5d0dd71
...
...
@@ -34,6 +34,10 @@ class SchemaTest extends TestCase
Schema
::
create
(
'newcollection_two'
,
null
,
[
'capped'
=>
true
,
'size'
=>
1024
]);
$this
->
assertTrue
(
Schema
::
hasCollection
(
'newcollection_two'
));
$this
->
assertTrue
(
Schema
::
hasTable
(
'newcollection_two'
));
$collection
=
Schema
::
hasCollection
(
'newcollection_two'
,
true
);
$this
->
assertTrue
(
$collection
[
'options'
][
'capped'
]);
$this
->
assertEquals
(
1024
,
$collection
[
'options'
][
'size'
]);
}
public
function
testDrop
()
:
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment