查询与Parse Rest API的关系(Querying Relations with Parse Rest API)

编程入门 行业动态 更新时间:2024-10-28 15:33:04
查询与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/owner

Thank 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/Dog

I 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

更多推荐

本文发布于:2023-08-06 11:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1450075.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:关系   Rest   Parse   API   Relations

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!