androidpointersparse-platformparse-serverparse-android-sdk

Parse Android SDK - Querying based on Pointer in Android SDK


The current questions on the internet about this didn't help (it's no duplicate).

Currently I'm experimenting with the GameScore example class.
Simply searching for a value in a column (here it's 1337 in the column "score") was as easy as this (in Kotlin):

val query = ParseQuery<ParseObject>("GameScore")
query.whereEqualTo("score", 1337)
query.findInBackground { objects, e ->
    ...
}

Then I wanted to implement a query to search for a value in an Array a pointer points to (based on THIS ARTICLE). For easier understand I just used the classes shown in the article.

He tells us that in Javascript you can do that with following code:

var visitQuery = new Parse.Query('Visit');  
visitQuery.equalTo('user', { "__type": "Pointer", "className": "_User", "objectId": userId });  
return visitQuery.find();  

Here you search for those objects of the Visit class which have the userId as their objectId.


So how do you convert that pointer query to Kotlin for the Android SDK? I currently don't know how to do this with Kotlin / Java syntax.

And if you achieve to execute that search succesfully, how can you seach for a value in a Array if the pointer points to an Array in the Visit class?

Thanks!


Solution

  • Try with whereMatchesQuery function. More details in this link. It will be something like the code below.

    var innerQuery = new Parse.Query("InnerClass");
    innerQuery.whereEqualTo("someField", "someValue");
    var query = new Parse.Query("OuterClass");
    query.whereMatchesQuery("someArrayField", innerQuery);