In my app, I am trying to create a feature where if a users UID is found in a document's array "likedBy", it sets the variable "isLiked" to true. I have a function called "checkForLikes" that is linked to my viewsheet.

So, my goal of my project is to set 'isLiked' to true if the logged in users UID ("uid") is found in the document's array.

However, in the function, I am getting the error "Cannot convert value of type 'Query' to expected condition type 'Bool'"

*PostViewModel.swift*

```
func checkForLikes(id: String){
        var doc = ref.collection("Posts")

        if doc.whereField("likedBy", arrayContains: uid){ /// error is here

            print("Found") /// temporary, eventually to be replaced with setting isLiked = true
        }
}

```

*PostRow.swift*

```
@State private var isLiked = false

```

```
HStack {
                Button(action: {if isLiked == false{
                    postData.addLike(id: post.id)
                    isLiked = true
                } else{
                    postData.unLike(id: post.id)
                    isLiked = false
                }}, label: {
                    Image(systemName: isLiked ? "heart.fill" : "heart")
                        .resizable()
                        .aspectRatio(contentMode: .fill)
                        .frame(width: 20, height: 20)
                        .foregroundColor(isLiked ? .red : .gray)
                }).onAppear(perform: {isLiked = postData.checkForLikes(id: post.id)})

                Text("\(post.likes)")
                    .font(.subheadline)
                    .foregroundColor(.gray)
                    .fontWeight(.light)

            }

        }

```

I *believe* I am on the right track with what I have, except I am facing that error. If I am on the wrong track, please let me know because this is my first time doing something like this.