查询与Parse Rest API的关系(Querying Relations with Parse Rest API)
我试图从类中获取关系对象。 我正在做的事情看起来像这样,但它不起作用。 有人知道我做错了什么吗?
curl -X GET \ -H "X-Parse-Application-Id: xxxxx" \ -H "X-Parse-REST-API-Key: xxxx" \ --data-urlencode 'where={"$relatedTo":{"object":{"__type”:"Relation","className”:”Dog","objectId":"xkxJOVMcMv"},"key”:"dogs"}}' \ https://api.parse.com/1/classes/owner谢谢 !
I am trying to get relation objects from a class. What I am doing looks something like this, but it is not working. Does anybody know what I could be doing wrong?
curl -X GET \ -H "X-Parse-Application-Id: xxxxx" \ -H "X-Parse-REST-API-Key: xxxx" \ --data-urlencode 'where={"$relatedTo":{"object":{"__type”:"Relation","className”:”Dog","objectId":"xkxJOVMcMv"},"key”:"dogs"}}' \ https://api.parse.com/1/classes/ownerThank you !
最满意答案
我假设你的所有者类与Dog类有一个关系字段,你想通过这种关系获得所有拥有的狗。 你应该这样做:
curl -X GET \ -H "X-Parse-Application-Id: xxxxx" \ -H "X-Parse-REST-API-Key: xxxx" \ --data-urlencode 'where={"$relatedTo":{"object":{"__type":"Pointer","className":"owner","objectId":"<ownerid>"},"key":"dogs"}}' \ https://api.parse.com/1/classes/DogI assume that your owner class has a relation field to Dog class and you want to get all the dogs someone owns via that relation. You should then to do this instead:
curl -X GET \ -H "X-Parse-Application-Id: xxxxx" \ -H "X-Parse-REST-API-Key: xxxx" \ --data-urlencode 'where={"$relatedTo":{"object":{"__type":"Pointer","className":"owner","objectId":"<ownerid>"},"key":"dogs"}}' \ https://api.parse.com/1/classes/Dog更多推荐
发布评论