Skip to content

Commit

Permalink
Access to interal collection object, fixes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Aug 15, 2013
1 parent 5c438b1 commit b910676
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ You can also perform raw expressions on the internal MongoCollection object, not
return $collection->find();
});

Or you can access the internal object directly:

User::raw()->find();

**Query Caching**

You may easily cache the results of a query using the remember method:
Expand Down
4 changes: 3 additions & 1 deletion src/Jenssegers/Mongodb/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,14 @@ public function truncate()
* @param closure $expression
* @return mixed
*/
public function raw($expression)
public function raw($expression = null)
{
if ($expression instanceof Closure)
{
return call_user_func($expression, $this->collection);
}

return $this->collection;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions tests/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public function testRaw()

$this->assertInstanceOf('MongoCursor', $cursor);
$this->assertEquals(1, $cursor->count());

$collection = DB::collection('users')->raw();
$this->assertInstanceOf('MongoCollection', $collection);
}

}

0 comments on commit b910676

Please sign in to comment.