簡體   English   中英

MongoDB使用Grails MongoDB插件查詢多對多查詢

[英]MongoDB Query many-to-many equivalent with Grails MongoDB plugin

我有兩個用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

對不起英語...

類Person {靜態mapWith =“ mongo”

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

static embedded = ['profile']

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM