anushka
anushka

Reputation: 345

Firestore: com.google.cloud.firestore.CollectionReference.where() not working

I am trying to check if a user exists in a nested field, but I keep getting this error.

No signature of method: com.google.cloud.firestore.CollectionReference.where() is applicable for argument types: (com.google.cloud.firestore.AutoValue_FieldPath, java.lang.String, java.lang.String) values: [responses.0, array-contains, UFZRW7MGV]

String[] queryPath = ["responses", Integer.toString(i)]

DocumentSnapshot userPoll = colRef.where(FieldPath.of(queryPath), "array-contains", user).get()
if(userPoll.exists()) 
    return true
}

What am I doing wrong here?

Upvotes: 0

Views: 177

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317497

As you can see from the API docs, a CollectionReference, subclass of Query, doesn't have a where() method. It looks like you want to use whereArrayContains() instead. Right now, it looks like you're assuming a node.js API instead of the Java API, which would be required for Grails.

Upvotes: 2

Related Questions