我们正在尝试在JSONStore
中存储任务列表,并在用户点击fetch
按钮时检索它。
观察到的行为:我们间歇地看到JSONStore
抛出exception
并且根本不会获取存储的任务。相同的源代码,重新部署时工作正常。意思是,任务按预期存储和提取。
抛出异常消息为{"src":"find","err":22,"msg":"INVALID_SEARCH_FIELD","col":"CollectionTasksName","usr":"jsonstore","doc":{},"res":{}}
我们的写作和阅读功能如下:
/**
* Function to add data to JSONStore collection
* @param collName: Collection name to add to
* @param dataToStore: data to store
* @param flag: flag for operation, if CLEAR, collection is cleared before adding the new data
* @param returnFunc: callback function for 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 to collection:'+collName);
console.log('Inside addFunc while adding to collection:'+collName);
WL.JSONStore.get(collName).add(data2Store, {push:true})
.then(function (dataAdded) {
WL.Logger.debug('Data added to the collection '+collName+'--Success');
console.log('Data added to the collection '+collName+'--Success');
returnFunc({'result': true});
})
.fail(function (errorObject) {
// Handle failure for any of the previous JSONStore operations (init, add).
WL.Logger.debug('Error adding data to the collection:'+collectn);
console.log('Error adding data to the collection:'+collectn);
returnFunc({'error':'Error adding the data'});
});
})
.fail(function (errobject) {
WL.Logger.debug(errobject.toString());
console.log(errobject.toString());
returnFunc({'error':'JSONStore Error adding the 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 for any of the previous JSONStore operations (init, add).
WL.Logger.debug('Error clearing collection:'+collName);
console.log('Error clearing collection:'+collName);
returnFunc({'error':'Error clearing the data'});
});
});
} else {
WL.Logger.debug('flag is not set as clear. About to call addFunc');
console.log('flag is not set as clear. About to call addFunc');
addFunc(collName,dataToStore,returnFunc);
}
}
阅读功能:
/**
* Function to fetch a collection data in array form using its name
* @param collName
* @param returnFunc: callback function for results handling
*/
function Storage_getArray(collName,returnFunc) {
console.log('SU: Storage get collection Array called for Collection:'+collName);
WL.Logger.debug('SU: Storage get collection Array called for 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: About to returnArray with length:'+returnArray.length);
console.log('About to returnArray with length:'+returnArray.length);
returnFunc(returnArray);
};
WL.Logger.debug('SU: About to start Collection '+collName+'. collections var:'+JSON.stringify(JSONStoreCollections));
console.log('SU: About to 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. about to find all');
console.log('SU: Collection init done. about to find all');
return WL.JSONStore.get(collName).findAll();
})
.then(funcRes)
.fail(function (err) {
WL.Logger.debug('SU: Error caught for JSONStore init for collection:'+collName+'. err:'+err.toString());
console.log('SU: Error caught for JSONStore init for collection:'+collName+'. err:'+err.toString());
var retErr = {"error": "JSONStore"};
returnFunc(err);
});
}
答案 0 :(得分:0)
此问题可能是产品中的缺陷,并作为支持票据/ PMR号码28639,756,000的一部分处理。如果需要,将在未来的iFix版本中提供修复。