簡體   English   中英

Worklight JsonStore高級查找

[英]Worklight JsonStore advanced find

如何使用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
});

您正在調用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的一些示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM