Skip to content

Commit 29dfdbf

Browse files
committed
Rewrite readme
1 parent d97bd16 commit 29dfdbf

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,32 @@ Tell your model to use the MongoDB model and set the collection (alias for table
6565

6666
}
6767

68-
*You can also specify the connection name in the model by changing the `connection` property.*
68+
If you are using a different database driver as the default one, you will need to specify the mongodb connection within your model by changing the `connection` property:
69+
70+
use Jenssegers\Mongodb\Model as Eloquent;
71+
72+
class MyModel extends Eloquent {
73+
74+
protected $connection = 'mongodb';
75+
76+
}
6977

7078
Everything else works just like the original Eloquent model. Read more about the Eloquent on http://laravel.com/docs/eloquent
7179

72-
Alternative Eloquent Setting
73-
----------------------------
80+
### Optional: Alias
81+
-------------------
82+
83+
You may also register an alias for the MongoDB model by adding the following to the alias array in `app/config/app.php`:
84+
85+
'Moloquent' => 'Jenssegers\Mongodb\Model',
86+
87+
This will allow you to use your registered alias like:
7488

75-
'aliases' => array(...
76-
'Moloquent' => 'Jenssegers\Mongodb\Model',
77-
);
78-
7989
class MyModel extends Moloquent {
8090

8191
protected $collection = 'mycollection';
8292

8393
}
84-
85-
Add
86-
87-
protected $connection = 'mongodb';
88-
89-
in the MyModel if you have multiple database connections and do not want to overwrite the primary database connection.
90-
9194

9295
Query Builder
9396
-------------
@@ -155,7 +158,7 @@ Examples
155158

156159
$users = User::whereIn('age', array(16, 18, 20))->get();
157160

158-
When using `whereNotIn` objects will be returned if the field is non existant. Combine with `whereNotNull('age')` to leave out those documents.
161+
When using `whereNotIn` objects will be returned if the field is non existent. Combine with `whereNotNull('age')` to leave out those documents.
159162

160163
**Using Where Between**
161164

0 commit comments

Comments
 (0)