parse-community / Parse-SDK-JS

The JavaScript SDK for Parse Platform
https://parseplatform.org
Apache License 2.0
1.33k stars 596 forks source link

Passing Parse object #213

Closed nitrag closed 8 years ago

nitrag commented 8 years ago

I am upgrading from v1.3.2 and I used to pass the full Parse Object from one CommonJS module to another via args. Now that I'm running the latest Parse JS SDK, I'm only getting this on the other end:

//after query before send to new commonjs controller
[DEBUG] :  Found CLUB: {"ACL":{"*":{"read":true},"15QSQgv93Z":{"read":true,"write":true}},"Address":"Atlanta, GA","ApprovalRequired":true,"MemberCount":1,"Name":"The Club Name","Public":true,"createdAt":"2016-02-11T22:01:29.361Z","updatedAt":"2016-02-11T22:01:31.796Z","objectId":"fqMZicTJbK"}

//upon receiving input in new controller
ARGS:{"club":{"_objCount":14,"className":"Club","id":"uPB7v2sb7G"}}

It's no longer the full object. What's happening here?

andrewimm commented 8 years ago

You're printing out the "surface view" of the object, but the fields are still there. Since 1.6.0, printing the object does not show any attributes, since they are provided under a non-enumerable property. If you want to print the attributes, they're available at object.attributes

andrewimm commented 8 years ago

.get(), .set(), etc all work the same. The only thing that changed there is printing behavior.

nitrag commented 8 years ago

Actually .get() not working is the issue:

var args = arguments[0] || {};
Ti.API.debug("ARGS:"+JSON.stringify(args));
Ti.API.debug("CLUB NAME: " + args.club.get("Name"));

output

[DEBUG] :  ARGS:{"club":{"_objCount":14,"className":"Club","id":"uPB7v2sb7G"}}
undefined is not a function (evaluating 'args.club.get(\"Name\")')

I have the exact same code working if I revert back to v1.3.2. thanks!

andrewimm commented 8 years ago

Okay, well it looks like the real issue is that get is not a function. I don't know what club is, but it's not a Parse.Object. Can you please provide a larger chunk of code that reliably reproduces your issue? Otherwise, there's no way we can debug this.

parse-github-bot commented 8 years ago

Thank you for your feedback. We prioritize issues that have clear and concise repro steps. Please see our Bug Reporting Guidelines about what information should be added to this issue.

Please try the latest SDK. Our release notes have details about what issues were fixed in each release.

In addition, you might find the following resources helpful:

nitrag commented 8 years ago

Sure it's a little more complicated so I'll put it in a private gist so I can delete it once we solve it.

So I'm developing in Appclerator Titanium. Specifically Alloy. Each Window in the App is a controller. The first controller is a list of "Clubs" (club_list.js) that gets its data from (parseClubs.js See line 45 where I am passing the full club object and notice how I am able to use club.get() fine there). When the user clicks on their club it passes the -whole- Parse Object (Club) to the second window which is the ARGS and output I showed you above.

Here's the gist. https://gist.github.com/nitrag/183c2cc15921ab7447f2#file-parseclubs-js-L45

Here's the expected output (working in 1.3.2)

[DEBUG] :  ARGS:{"club":{"Address":"Atlanta, GA","MemberCount":1,"ApprovalRequired":true,"Name":"Atlanta 4Runner's","Public":true,"ACL":{"setRoleWriteAccess":{},"getPublicWriteAccess":{},"setWriteAccess":{},"toJSON":{},"setPublicWriteAccess":{},"setPublicReadAccess":{},"getReadAccess":{},"getRoleReadAccess":{},"getPublicReadAccess":{},"setReadAccess":{},"permissionsById":{"*":{"read":true},"15QSQgv93Z":{"write":true,"read":true}},"_setAccess":{},"setRoleReadAccess":{},"getRoleWriteAccess":{},"getWriteAccess":{},"_getAccess":{}},"objectId":"fqMZicTJbK","createdAt":"2016-02-11T22:01:29.361Z","updatedAt":"2016-02-11T22:01:31.796Z"}}
[DEBUG] :  CLUB NAME: Atlanta 4Runner's
nitrag commented 8 years ago

Actually it's working in 1.5.0. I forgot I was able to upgrade to that. I'm trying to get to 1.7.1 now so that I can stay current with Parse-Server.

parse-github-bot commented 8 years ago

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

nitrag commented 8 years ago

This issue still exists but it's probably related to Appcelerator Titanium. I've implemented a workaround on that end.