Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

parse.com - cloud code - what do i do with a pointer?

Someone doesn't understand what i want. I want to know what i can do with a pointer.

I have js cloud code.

I have a pointer.

What can i do with it?

Example:

var query = new Parse.Query("Messages"); //POINTER QUERY
console.log(userMessages[0].get("messageId"));
console.log("end2");
query.equalTo("objectId",userMessages[position].get("messageId"));

In the example, userMessages is the result of a prior cloud query.

This line

console.log(userMessages[0].get("messageId"));

helpfully outputs

{"__type":"Pointer","className":"Messages","objectId":"5J4eOletgz"}

This is less useful than you might imagine. I cannot seem to call the objectId from it, and the query

query.equalTo("objectId",userMessages[position].get("messageId"));
query.find ({ ... });

returns nothing. Note that the query should find the pointer-object the pointer-points-to, but instead it helpfully throws the error

Error: 102 bad special key: __type

Which is just about useless.

What can i do with a pointer? Why don't the people at parse.com bother to write this stuff up anywhere?

That second question is more like a buddhist koan for them to meditate over, no need to respond!

like image 812
bharal Avatar asked Dec 19 '22 14:12

bharal


1 Answers

you can use:

userMessagesQuery.include("messageId")

before you execute your query that returns userMessages and you will get the entire object in "messageId" instead of just a pointer.

Also you use

userMessages[0].get("messageId").fetch({success:function(){}})

to get the full object if you don't want to use "include"

Suggestion: I'd rename "messageId" to "message" to make it clear that it's an object pointer and not an ID field.

like image 180
Rip Ryness Avatar answered Jan 31 '23 01:01

Rip Ryness