2013-03-22 49 views
0

我有MongoDB Grails PLUGIN這樣的映射兩類:MongoDB的查詢許多一對多相當於使用Grails的MongoDB插件

類人:

class Person { 
    static mapWith="mongo" 

    String name 
    String email 

    static hasMany = [profiles: Profile] 

    static belongsTo = Profile 


    String toString(){ 
     return name +" - " + (profiles) 
} } 

和類簡介:

class Profile{ 

static mapWith="mongo" 

String abbreviation 
String description 
static hasMany = [people: Person] 



String toString(){ 
    return abbreviation + " - " + description 
}} 

如何查詢使用mongo提供的查找器將每個配置文件返回給用戶?

mongo查詢可能也有用!

此取景器不返回任何

def people = Profile.findAllByAbbreviation("example").people 

對不起英文...

+0

簡介.findAllByAbbreviation(「example」)*。people? – 2013-03-22 23:12:12

回答

0

類Person { 靜態mapWith = 「蒙戈」

String name 
String email 
List<Profile> profile= new ArrayList<Profile>(); 

static embedded = ['profile'] 

}