I have a JSON object to my collection with JSONStore like this:
{
name : 'name1',
industry : ['Banking', 'Energy', 'Insurance', 'Media', 'Retail', 'Telco', 'Travel'],
buyer : ['CMO'],
link : 'foo.com'
}
But, how is possible declare the industry field into searchFields?, in order to search a pattern in the array.
Cheers
There's no
array
type for search fields. You can only index values in objects that arestring
,boolean
,number
andinteger
.You could change:
to:
and then use the following search field:
{'industry.name' : 'string'}
. That will enable you to do something likeWL.JSONStore.get('collection').find({'industry.name' : 'Banking'}, {exact: true})
and get back an object like this one:This is documented under the search field section of general terminology in the documentation here.
That would mean writing code like this to change the data being added to the collection:
Alternatively, you could also change it into a string:
and get back something like this:
Then you can use the search field
{industry : 'string'}
and do something likeWL.JSONStore.get('collection').find({industry: 'Energy'}, {exact: false})
to get objects that haveEnergy
somewhere in theindustry
value string.FYI - Feature requests here.