As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Can I add KinveyReferences and other custom Arrays to the User entity?
E
Edward
started a topic
about 10 years ago
For my app I want every user to have a list of other users they are "friends" with, how can I do this?
1 Comment
E
Edward
said
about 10 years ago
The User class extends GenericJson, which is used throughout the library as our JSON representation. This provides both put(String key, Object value) as well as get(String key) for setting and retrieving arbitrary JSON data.
To add new data to your User object, try something like this:
//add "myJsonKey":"myJsonValue" to the current User object
If you want to resolve KinveyReferences on the current user, you can use one of the variations of the retrieve method. This retrieve methods to resolve KinveyReferences all take a String[]. which contains all JSON keys to resolve. In this case, it is "friend" as it was set above.
kinveyClient.user().retrieve(new String[]{"friend"}, new KinveyUserCallback() {
@Override
public void onSuccess(User result) {
//got the user with friend resolved
}
@Override
public void onFailure(Throwable error) {
//uh oh, something went wrong
}
});
KinveyReferences can also be set in Arrays, so you can call store multiple references in one field.
Edward