Eddy
Eddy

Reputation: 3703

Value of pointer in Parse.com javascript

I have a pointer in one of my Parse.com datastore objects. I need to extract the objectId from it. This is the json Customer object in my cloud code:

"Customer":{"__type":"Pointer","className":"_User","objectId":"oowk8Vgcyg"},

I tried

var customer = request.object.get("Customer")

This prints out [object Object].

Now how do I get the objectId from it? I tried

customer.objectId

or

customer[objectId]

or

customer["objectId"]

or the various with or without quotes

customer.get(objectId)

but none works. What's the correct syntax?

Upvotes: 0

Views: 660

Answers (2)

user4902356
user4902356

Reputation: 1

You can get it like this.

For example I want to get the objectId of the class User that has a pointer from another class

var userId = object.get('User').id;

hope it helps.

Upvotes: 0

howderek
howderek

Reputation: 2244

Try using customer.id

The Parse object looks different than the JSON you send.

https://www.parse.com/docs/js/guide#objects-retrieving-objects

Upvotes: 1

Related Questions