Skip to content

Commit bcda997

Browse files
committed
Added more documentation to use "_id" as the primary key on your models.
1 parent c086f0d commit bcda997

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: README.markdown

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Model files need to have mongoSchema property - or make use of the schemaless be
4848

4949
Mongo uses a primary key named "\_id" (cannot be renamed). It can be any format you like but if you don't explicitly set it Mongo will use an automatic 24 character (uu)id.
5050

51+
To use the "\_id" as the default primary key in CakePHP, change the `$primaryKey` property to "\_id" in your model or in the AppModel.
52+
53+
class AppModel extends Model {
54+
public $primaryKey = '_id';
55+
}
56+
5157
Before you start, you may find it useful to see [a model sample.](http://github.com/ichikaway/mongoDB-Datasource/blob/master/samples/models/post.php)
5258
There are also some sample [controller actions: find,save,delete,deleteAll,updateAll](http://github.com/ichikaway/mongoDB-Datasource/blob/master/samples/controllers/posts_controller.php) note that your controller code needs no specific code to use this datasource.
5359

0 commit comments

Comments
 (0)