开发者

Grails + MongoDB: what's a replacement for association query criteria?

The MongoDB plugin for Grails (mongodb 1.0-M5) doesn't (yet) support queries of type AssociationQuery. This means I can't d开发者_Python百科o this:

// Find all instances of MyDomainClass whose myHasOneObject.id is in listOfIds
// Throws exception b/c Mongo doesn't support AssociationQuery
MyDomainClass.withCriteria {
    myHasOneObject {
        inList('id', $listOfIds)
    }
    [...]

// FYI, class declaration looks like this:
class MyDomainClass {
    AnotherDomainClass myHasOneObject
    [...]

What's an alternative way to do queries like this in MongoDB in Grails?

Thanks!


MongoDB doesn't support join queries, so you need to do 2 queries or denormalize your data

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜