Ok, looking at the Mongo DB source code, it doesn't do any association queries. So i'm written a behavior to solve it.
On Jul 18, 4:55 pm, LordG <[email protected]> wrote: > Hello Bakers, > > I'm busy testing Models with MongoDB. I have two Models: Recipe and > Tag. > > class Recipe extends AppModel { > var $name = 'Recipe'; > > var $mongoSchema = array( > 'name' => array('type' => 'string'), > 'description' => array('type' => 'string'), > 'tags' => array('type' => 'array'), //the tags "tag" value > 'created' => array('type' => 'datetime'), > 'modified' => array('type' => 'datetime'), > ); > > var $hasAndBelongsToMany = array( > 'Tag' => > array( > 'className' => 'Tag', > 'joinTable' => 'recipe', > 'foreignKey' => '_id', > 'associationForeignKey' => 'tags', > 'unique' => true, > ) > ); > > } > > class Tag extends AppModel { > var $name = 'Tag'; > > var $mongoSchema = array( > 'tag' => array('type' => 'string'), > 'description' => array('type' => 'string'), > 'created' => array('type' => 'datetime'), > 'modified' => array('type' => 'datetime'), > ); > > var $hasAndBelongsToMany = array( > 'Recipe' => > array( > 'className' => 'Recipe', > 'joinTable' => 'recipe', > 'foreignKey' => 'tags', > 'associationForeignKey' => '_id', > 'unique' => true, > ) > ); > > } > > Recipe has many tags and vica versa, but how do I correctly represent > this so that it maps correctly with MongoDB? > > Futhermore, how do I ensure that the relationships are managed > correctly when we either delete a recipe or delete a tag? > > Thanks. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
