android - JSON Store fails intermittently in MobileFIrst hybrid app -


we're trying store list of tasks in jsonstore , retrieve user clicks on fetch button.

observed behavior: see intermittently, jsonstore throws exception , won't fetch stored tasks @ all. same source code, when re-deployed works fine. meaning, tasks stored , fetched expected.

exception thrown message {"src":"find","err":22,"msg":"invalid_search_field","col":"collectiontasksname","usr":"jsonstore","doc":{},"res":{}}

our writing , reading functions below:

/** * function add data jsonstore collection * @param collname: collection name add * @param datatostore: data store * @param flag: flag operation, if clear, collection cleared before adding new data * @param returnfunc: callback function results handling  */ function storage_add(collname,datatostore,flag,returnfunc) { wl.logger.debug('su: storage add function called.'); console.log('su: storage add function called.');  var result = {'result': true}; var collections = {}; collections[collname] = {         searchfields: {'id': 'string', 'processid' : 'string'} }; var addfunc = function(collectn,data2store,returnfunc) {     wl.jsonstore.init(collections)     .then(function() {         wl.logger.debug('inside addfunc while adding collection:'+collname);         console.log('inside addfunc while adding collection:'+collname);         wl.jsonstore.get(collname).add(data2store, {push:true})             .then(function (dataadded) {                 wl.logger.debug('data added collection '+collname+'--success');                 console.log('data added collection '+collname+'--success');                 returnfunc({'result': true});             })             .fail(function (errorobject) {                 // handle failure of previous jsonstore operations (init, add).                 wl.logger.debug('error adding data collection:'+collectn);                 console.log('error adding data collection:'+collectn);                 returnfunc({'error':'error adding data'});             });          })     .fail(function (errobject) {         wl.logger.debug(errobject.tostring());         console.log(errobject.tostring());         returnfunc({'error':'jsonstore error adding data'});     }); }; if(flag=='clear') {     wl.jsonstore.init(collections)     .then(function() {         wl.logger.debug('with flag clear, opened collection:'+collname);         console.log('with flag clear, opened collection:'+collname);         wl.jsonstore.get(collname).removecollection()             .then(function () {                 wl.logger.debug('cleared collection --success');                 console.log('cleared collection --success');                 // handle success.                 addfunc(collname,datatostore,returnfunc);             })             .fail(function (errorobject) {                 // handle failure of previous jsonstore operations (init, add).                 wl.logger.debug('error clearing collection:'+collname);                 console.log('error clearing collection:'+collname);                 returnfunc({'error':'error clearing data'});             });          });  } else {     wl.logger.debug('flag not set clear. call addfunc');     console.log('flag not set clear. call addfunc');     addfunc(collname,datatostore,returnfunc); }    } 

reading function:

/** * function fetch collection data in array form using name * @param collname * @param returnfunc: callback function results handling */ function storage_getarray(collname,returnfunc) { console.log('su: storage collection array called collection:'+collname); wl.logger.debug('su: storage collection array called collection:'+collname); var returnarray = [];  var collectionname = collname; var jsonstorecollections = {}; jsonstorecollections[collectionname] = {}; jsonstorecollections[collectionname].searchfields = {'id': 'string', 'processid' : 'string'};  var funcres = function(res) {     wl.logger.debug('su: inside funcres. no. of results:'+res.length);     console.log('no. of results:'+res.length);     wl.logger.debug('res stringified:'+json.stringify(res));     console.log('res stringified:'+json.stringify(res));     if (res.length >= 1) {         console.log('res has values.');         $.each(res, function (index, val) {             returnarray.push(val.json); //push values here         });     }     wl.logger.debug('su: returnarray length:'+returnarray.length);     console.log('about returnarray length:'+returnarray.length);     returnfunc(returnarray); };  wl.logger.debug('su: start collection '+collname+'. collections var:'+json.stringify(jsonstorecollections)); console.log('su: start collection '+collname+'. collections var:'+json.stringify(jsonstorecollections)); wl.jsonstore.init(jsonstorecollections) .then(function () {           //wl.logger.debug('ts init done');         wl.logger.debug('su: collection init done. find all');         console.log('su: collection init done. find all');       return wl.jsonstore.get(collname).findall();  }) .then(funcres) .fail(function (err) {         wl.logger.debug('su: error caught jsonstore init collection:'+collname+'. err:'+err.tostring());         console.log('su: error caught jsonstore init collection:'+collname+'. err:'+err.tostring());         var reterr = {"error": "jsonstore"};         returnfunc(err); }); } 

this issue may defect in product , handled part of support ticket/pmr number 28639,756,000. fix available in future ifix releases if need be.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -