search - Declare array into searchFields Worklight JSONStore -
i have json object collection jsonstore this:
{ name : 'name1', industry : ['banking', 'energy', 'insurance', 'media', 'retail', 'telco', 'travel'], buyer : ['cmo'], link : 'foo.com' } but, how possible declare industry field searchfields?, in order search pattern in array.
cheers
there's no array type search fields. can index values in objects string, boolean, number , integer.
you change:
{ industry : ['banking', 'energy'] } to:
{ industry : [{name: 'banking'}, {name: 'energy'}] } and use following search field: {'industry.name' : 'string'}. enable wl.jsonstore.get('collection').find({'industry.name' : 'banking'}, {exact: true}) , object one:
[{_id: ..., json: {name: ..., industry: [..., {name: banking}, ...], buyer: ..., link: ...}}] this documented under search field section of general terminology in documentation here.
that mean writing code change data being added collection:
var output = []; ['banking', 'energy', 'insurance', 'media'].foreach(function (element) { output.push({name: element}); }); console.log( json.stringify(output, null, ' ') ); alternatively, change string:
{industry : ['banking', 'energy', 'insurance', 'media'].tostring() } and this:
{industry : "banking,energy,insurance,media"} then can use search field {industry : 'string'} , wl.jsonstore.get('collection').find({industry: 'energy'}, {exact: false}) objects have energy somewhere in industry value string.
fyi - feature requests here.
Comments
Post a Comment