MongoDB使用Grails MongoDB插件查询多对多等效项

时间:2013-03-22 12:14:33

标签: mongodb grails

我有两个用MongoDB Grails PLUGIN映射的类:

班主任:

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

对不起英语......

1 个答案:

答案 0 :(得分:0)

class Person {      static mapWith =“mongo”

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

static embedded = ['profile']

}