I'm trying to query my collections with compound queries in Android. Specifically, I am trying to get a single value out of a column based upon another column, much like in SQL: SELECT element FROM table WHERE element2 = 'value'.
I cannot for the life of me figure it out. I understand that I can use the AND function to attach a condition, much like the WHERE in the above SQL example. However, I do not understand how to pull just a value. Functions such as ALL or REGEX take multiple parameters.
I would like to be able to declare what Key I want data returned and then my condition, much like the following:
function foo(String email)
Query qry = new Query();
over 4 years ago
Hey, sorry for the delay in getting back to you, I was out of the office for a few days.
Take a look at the javadocs for the query class, this might offer some insight into the methods available: http://devcenter.kinvey.com/android/reference/api/java/reference/com/kinvey/java/Query.html
basically, most of those query methods take two arguments-- the first is the json key you with to perform the action on, and and the second is the value-- for example:
Query qry = new Query().equals("Email", email)
will return all entities which have a field "Email", which contain the value email. Using this query, you will get an array, which you can iterate through and grab all the values for the "Name" field.
Note that the all("key", ["value1", "value2"]) method will return entities whose "key" field contains either "value1" or "value2"
as for the `SELECT element` aspect of it, this isn't currently supported by the android library but I have opened a ticket for it. The issue is that this will return a different JSON type than appdata is expecting (which is defined with generics), so I need to figure out how best to approach this without adding too much confusion.