【问题标题】:Worklight JsonStore advanced findWorklight JsonStore 高级查找
【发布时间】:2014-09-19 08:16:41
【问题描述】:

如何使用 QueryPart 在 Worklight JSONStore 中使用高级查找?

我尝试了以下代码,但它无法正常工作,我怀疑我是否正确调用了 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
});

【问题讨论】:

    标签: ibm-mobilefirst jsonstore


    【解决方案1】:

    您正在调用 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
    });
    

    供将来参考, here is the API 和一些examples on how to use the Javascript JSONStore API.

    【讨论】:

    • 谢谢丹尼尔。它现在工作正常。我正在尝试使用 Query 作为对象传递的 advancedFind。
    猜你喜欢
    • 2013-01-13
    • 2013-02-15
    • 2013-08-13
    • 2014-08-10
    • 2013-02-14
    • 2014-06-29
    • 2014-12-07
    • 2015-02-16
    • 2013-01-22
    相关资源
    最近更新 更多