let`s say I have two objects (classes) Category and Work. I want to save new Work with Category relation. Any ideas how to do that?
2 Answers
This is a pretty basic thing covered in the documentation here.
In your case you would have a category property on your Work object that would be an object pointer to a Category class (table).
// assuming you have myWork and myCategory as instances of ParseObject
myWork.put('category', myCategory);
If you only have the objectId of the Category then you do the following:
myWork.put('category', ParseObject.createWithoutData('Category', categoryId));
2 Comments
BenG
Yes, I found it. And my mistake was to create relation instead of pointer column. Thanks!
stanley santoso
But this is a way to make pointer. how to make relations? say you want to create new works that are related to a specific category?
But now I want to get info from database.
ParseQuery<ParseObject> query = ParseQuery.getQuery("Event");
query.whereEqualTo("user", userID);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> commentList, ParseException e) {
System.out.println(commentList);
}
});
And after that I got empty response.
SOLVED.