解析到Kinvey查询

时间:2016-03-02 02:38:05

标签: swift parse-platform kinvey

由于关闭,我刚刚从解析迁移到kinvey,我想知道是否有人可以帮我弄清楚这个查询在kinvey SDK中会是什么样子。这是:

let innerP1 = NSPredicate(format: "sender = %@ AND other = %@", userName, otherName)
let innerQ1:PFQuery = PFQuery(className: "Messages", predicate: innerP1)

let innerP2 = NSPredicate(format: "sender = %@ AND other = %@", otherName, userName)
let innerQ2:PFQuery = PFQuery(className: "Messages", predicate: innerP2)

        let query = PFQuery.orQueryWithSubqueries([innerQ1,innerQ2])
        query.addAscendingOrder("createdAt")
        query.findObjectsInBackgroundWithBlock {
            (objects:[PFObject]?, error:NSError?) -> Void in  //UPDATE THIS
}

1 个答案:

答案 0 :(得分:0)

作为一个广泛的例子......

http://devcenter.kinvey.com/phonegap/reference/api/Kinvey.Query.html

var query = new Kinvey.Query();
var query2 = new Kinvey.Query();
query.equalTo("sender",userName).and().equalTo("other",other name);
query2.equalTo("sender",otherName).and().equalTo("other",userName);
query.or(query2);
query.ascending("_kml.lmt"); //last modified time

var promise = Kinvey. DataStore.Find("group name",query);
promise.then(successfunction,fail function);

另请注意,这是一个关于phonegap库的示例,请根据您的具体情况查看适用于Android或iOS的kinvey参考。