1

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 2

2

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));
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, I found it. And my mistake was to create relation instead of pointer column. Thanks!
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?
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.