views:

35

answers:

1

Hi,

I'm trying to make a Match model which includes the players lined up during that match. So each Match hasMany Players and each Player hasmany Matches.

match = {
 '_id' : ObjectID('978tqwbi9873gofiu'),
 'home' : 'Argentina',
 'away' : 'Brazil',
 'lineup-home' : [
   {'name' : 'Lionel Messi',
    'goals' : '2',
    'timeon' : 30
   },
   {'name' : 'Diego Maradonna',
    'goals' : '0',
    'timeon' : 0
   },
   {'name' : 'Sergio Aguero',
    'goals' : '0',
    'timeon' : 0
   }
 ]
 }  

How do I add these 'lineup-home' relations in my CakePHP model to work with my mongoDB? This is how my model looks like...

    class Match extends AppModel {
    //var $useDbConfig = 'mongo';
    var $mongoSchema = array(
        'home' => array('type' => 'string'),
        'away' => array('type' => 'string'),
        'lineup-home' => ???
    );
}

Thank you.

A: 

I think that using 'lineup-home' => 'array' will do the trick..

dejavu
Are you sure? It somewhat looks strange and it doesn't seem to work:var $mongoSchema = array( 'home' => array('type' => 'string'), 'away' => array('type' => 'string'), 'lineup-home' => array('type' => 'array'));
octavian

related questions