Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs: Access to nested child elements in json field #91

Open
keltik85 opened this issue Jul 22, 2016 · 0 comments
Open

Update docs: Access to nested child elements in json field #91

keltik85 opened this issue Jul 22, 2016 · 0 comments

Comments

@keltik85
Copy link

I may be to stupid to read between the lines in the docs, but i cant get the following to work:

def instance = new TestMapJson(data: [name: "Iván", age: 35, hasChilds: true, childs: [[name: 'Judith', age: 8], [name: 'Adriana', age: 5],[name: 'Peter', age: 8]]])
instance.save()
def instance2 = new TestMapJson(data: [name: "Iván", age: 35, hasChilds: true, childs: [[name: 'Judith', age: 38], [name: 'Adriana', age: 25],[name: 'Peter', age: 18]]])
instance2.save()
def instance3 = new TestMapJson(data: [name: "Iván", age: 35, hasChilds: true, childs: [[name: 'Judith', age: 1], [name: 'Adriana', age: 5],[name: 'Andre', age: 8]]])
instance3.save()
//give me instances of TestMapJson, which have at least one child with the age of 8
def result = TestMapJson.withCriteria {
    pgJsonHasFieldValue 'data', 'childs.age', '8'
}
//i would expect instance1 and instance2 to be returned
//give me instances of TestMapJson, which have at least one child with the age of 8 which is named Peter
def result = TestMapJson.withCriteria {
    pgJsonHasFieldValue 'data', 'childs.age', '8'
    pgJsonHasFieldValue 'data', 'childs.name', 'Peter'
}
//i would expect instance1 to be returned

Is there a use case for this or am I trying to do stuff that is not implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant