【问题标题】:MongoDB Query many-to-many equivalent with Grails MongoDB pluginMongoDB 使用 Grails MongoDB 插件查询多对多等价物
【发布时间】:2013-03-22 12:14:32
【问题描述】:

我有两个类用 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

对不起英文...

【问题讨论】:

  • Profile.findAllByAbbreviation("example")*.people ?

标签: mongodb grails


【解决方案1】:

类人{ 静态 mapWith="mongo"

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

static embedded = ['profile']

}

【讨论】:

    猜你喜欢
    • 2011-04-17
    • 2012-05-18
    • 1970-01-01
    • 2019-02-19
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多