【发布时间】:2015-05-21 03:36:47
【问题描述】:
Windows 中的 IBM MobileFirst 6.3.0
当我使用 Json Store 时,我很少遇到警告和异常。
由于我使用的是从 Eclipse 市场安装的最新 MobileFirst 工作室,因此可以忽略此问题或提供任何修复程序
JSON 存储代码:
var jsonStoreObject = { };
jsonStoreObject.collectionName = 'people';
jsonStoreObject.collections = {
people : {
searchFields : {name: 'string', age: 'integer'}
}
};
jsonStoreObject.options = {
username : "Hello",
password : "123"
};
function openJSON(){
WL.JSONStore.init(jsonStoreObject.collections, jsonStoreObject.options)
.then(function(data) {
WL.Logger.info("After Init::"+ JSON.stringify(data));
return WL.JSONStore.get(jsonStoreObject.collectionName).findAll();
})
.then(function(findAllResult) {
WL.Logger.info("findAllResult::"+ JSON.stringify(findAllResult));
if (findAllResult.length == 0) {
var data = [{name: 'carlos', age: 10}];
return WL.JSONStore.get(jsonStoreObject.collectionName).add(data);
}
})
.fail(function (errorObject) {
console.log("Json Failure:: " + WL.JSONStore.getErrorMessage(errorObject));
});
}
例外/警告:
03-18 05:23:17.332: I/dalvikvm(1669): 找不到方法 org.json.JSONException.,从方法中引用 com.worklight.androidgap.jsonstore.security.DPKBean.
03-18 05:23:17.332: W/dalvikvm(1669): VFY: 无法解析直接方法 34098: Lorg/json/JSONException;。 (Ljava/lang/Throwable;)V
另外,当我第一次调用 openJSON() 时,我曾经得到以下日志,比如数据库已经存在。
03-18 06:50:05.518: D/JSONSTORE(1053): JSONStoreLogger.logDebug in JSONStoreLogger.java:174 :: 供应数据库“人”(已经 存在:假)
【问题讨论】: