简体   繁体   中英

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.

Problem

If you're reading this question, perhaps you're getting the following error in your Cloud Code error log

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

when you try to call the .query() method of a Parse.Relation .

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.

I should have been calling .relation('RELATION_KEY') instead. I know this is was in the Parse.Object documentation, but I saw "get" and stopped reading. My mistake.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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