i have a code like this on grails mongodb
//myDomain
class Plugin {
List<String> projects = []
//projects has name and description
}
//myController
def query = null
if (params.q != null)
{
def q = '%'+ params.q +'%'
query = Plugin.where {
(projects.name =~ q || projects.name ==~ q)
}
}
//return null
why i can’t find plugin by projects.name?
From the property definition
the elements of projects are Strings, that’s why you can not query
projects.name, which is not known to GORM.And in your last comment, the value in a projects instance
"projects": { "0": { "description": "123", "name": "cms" }, "1": { "description": "cms", "name": "codebucks" } }looks like a Map, where the project number is the key and a inner map containing name and description is the value, rather than a List.To serve your purpose, you need to modify your domain class definition to ensure consistency between your model and data.