解析服务器查询以查找用户名下的关键字

Parse Server Query to find keywords under username

我一直在尝试查询 class "posts" 中的所有行,首先属于当前用户,然后在 [=22= 列中有 "fish" ] 在同一个 class "posts".

我可以成功获取属于当前用户的所有帖子:

let posts = PFQuery(className: "posts")
    posts.whereKey("username", equalTo: PFUser.currentUser()!.username!)
    posts.countObjectsInBackgroundWithBlock ({ (count:Int32, error:NSError?) in
        if error == nil {
            header.posts.text = "\(count)"
        }

我尝试使用

在第一个 whereKey 下简单地添加另一个 whereKey
posts.whereKey("fish", equalTo: "fish")

但这没有用。关于我需要做什么来完成这个有什么想法吗?

在解析中,您可以根据需要添加任意数量的条件。从您的代码来看,我认为问题出在您的第二个 where 键上。在你的第二个 where 键中,你试图找到 fish 列下的所有鱼,而在你的问题中,你写道你想找到 type[ 下的所有鱼=18=] 列所以请更改此

posts.whereKey("fish", equalTo: "fish")

为此:

posts.whereKey("type", equalTo: "fish")