0

In Parse I've two classes with a many-to-many relation, for example items and categories. I've created in the class items a relation with categories and all work fine with querying and updating. My problem is when I need to change the items relation with linked categories.

As far as I know, if I need to change the relation of items with categories, I first need to delete all categories relation with RemoveRelation and later re-add them with AddRelation. To do that I need to fetch all categories objectId from my item.

How can I do that with a REST API call?

1 Answer 1

1

I assume you have an item with objectId of xyz in your Items class. In that class you have a Relation field called categories which holds a list of objects from Category class. To get all the category objects from that relationship, you can do the following REST call using curl:

curl -X GET -H "X-Parse-Application-Id: xxx"   -H "X-Parse-REST-API-  Key: xxx" -H "Content-Type: application/json"  
-G --data-urlencode 'where={"$relatedTo":{"object":{"__type":"Pointer","className":"Items","objectId":"xyz"},
"key":"categories"}}' https://api.parse.com/1/classes/Category
Sign up to request clarification or add additional context in comments.

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.