简体   繁体   English

解析云代码:在关系上调用.query()时,“无法调用null的方法'_toPointer'

[英]Parse Cloud Code: “Cannot call method '_toPointer' of null” when calling .query() on a relation

This is something that I struggled with, and couldn't find a quick answer for. 这是我努力的事情,无法找到快速答案。 Ultimately, I realized that I wasn't reviewing the Parse documentation properly. 最终,我意识到我没有正确地审查Parse文档。

Problem 问题

If you're reading this question, perhaps you're getting the following error in your Cloud Code error log 如果您正在阅读此问题,可能是您的Cloud Code错误日志中出现以下错误

Result: TypeError: Cannot call method '_toPointer' of null

when you try to call the .query() method of a Parse.Relation . 当您尝试调用Parse.Relation.query()方法时。

Solution

Consider that you may be retrieving the relation incorrectly, in the first place. 考虑到您可能首先错误地检索关系。 I spent quite a while struggling to understand why, if I called the .get('RELATION_KEY') method of a Parse.Object , I kept getting this error. 我花了很Parse.Object努力理解为什么,如果我调用Parse.Object.get('RELATION_KEY')方法,我不断得到这个错误。

I should have been calling .relation('RELATION_KEY') instead. 应该一直在调用 .relation('RELATION_KEY') I know this is was in the Parse.Object documentation, but I saw "get" and stopped reading. 我知道这 在Parse.Object文档中,但我看到“得到”并停止阅读。 My mistake. 我的错。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM