如何使用高级查找在工作光JSONStore中使用QueryPart?
我尝试过以下代码,但它不能正常工作,我怀疑我是否正确地调用了advancedFind。
var query = WL.JSONStore.QueryPart().equal('age', 35);
var collectionName = "people";
WL.JSONStore.get(collectionName).find(query).then(function(arrayResults) {
// if data not present , get the data from DB
if (arrayResults.length == 0) {
} else {
}
}).fail(function(errorObject) {
alert("fail" + errorObject);
// handle failure
});发布于 2014-07-28 12:42:14
您正在调用find()方法。您要调用的是advancedFind()。另外,advancedFind接收一个查询部件数组,而不仅仅是一个查询部分。您的代码应该如下所示:
var queryPart = WL.JSONStore.QueryPart().equal('age', 35);
var collectionName = "people";
WL.JSONStore.get(collectionName).advancedFind([queryPart]).then(function(arrayResults) {
// if data not present , get the data from DB
if (arrayResults.length == 0) {
} else {
}
}).fail(function(errorObject) {
alert("fail" + errorObject);
// handle failure
});供将来参考,这是API和一些关于如何使用Javascript JSONStore API的示例。
https://stackoverflow.com/questions/24990234
复制相似问题