Skip to content

Commit b910676

Browse files
committed
Access to interal collection object, fixes #19
1 parent 5c438b1 commit b910676

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ You can also perform raw expressions on the internal MongoCollection object, not
237237
return $collection->find();
238238
});
239239

240+
Or you can access the internal object directly:
241+
242+
User::raw()->find();
243+
240244
**Query Caching**
241245

242246
You may easily cache the results of a query using the remember method:

src/Jenssegers/Mongodb/Builder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,14 @@ public function truncate()
410410
* @param closure $expression
411411
* @return mixed
412412
*/
413-
public function raw($expression)
413+
public function raw($expression = null)
414414
{
415415
if ($expression instanceof Closure)
416416
{
417417
return call_user_func($expression, $this->collection);
418418
}
419+
420+
return $this->collection;
419421
}
420422

421423
/**

tests/QueryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ public function testRaw()
9696

9797
$this->assertInstanceOf('MongoCursor', $cursor);
9898
$this->assertEquals(1, $cursor->count());
99+
100+
$collection = DB::collection('users')->raw();
101+
$this->assertInstanceOf('MongoCollection', $collection);
99102
}
100103

101104
}

0 commit comments

Comments
 (0)