Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit objects in Parse.Cloud defined function before response.success #1916

Closed
CiraciNicolo opened this issue May 26, 2016 · 7 comments
Closed

Comments

@CiraciNicolo
Copy link

I've defined a parse cloud function that allow me to retrive some objects and I would "add" a calculated property to this object without saving that "new" property.

Let me be clear: in this scenario we have a Feed and a FeedLike entity, I've define a parse.cloud function that returns me the feeds and I would like to edit the feed object adding a calculated property to know if a the query user liked that post. I can retrive Feed and FeedLike both, but if I edit the feed property "liked" (On parse dashboard is a boolean type, undefined for all objects) the response is always nil.

@CiraciNicolo CiraciNicolo changed the title Edit object in Parse.Cloud defined function before response.success Edit objects in Parse.Cloud defined function before response.success May 26, 2016
@rudyk5
Copy link

rudyk5 commented May 26, 2016

Pusingg...

@drew-gross
Copy link
Contributor

The dashboard doesn't use this cloud function, it queries the class directly, so it wouldn't get this extra info.

@CiraciNicolo
Copy link
Author

I'm not talking about the dashboard, the requests are made ​​by the iOS/Android SDKs

@drew-gross
Copy link
Contributor

Interesting. Adding properties in a cloud function should work fine. Can you include your code, and the server logs that demonstrate the issue? Then we can make a test case.

@hramos
Copy link
Contributor

hramos commented Jul 27, 2016

We're closing this issue due to inactivity.

If this is a bug you care about that is not getting attention, consider opening a pull request with a fix.

@hramos hramos closed this as completed Jul 27, 2016
@deveristica
Copy link

Actually I think I have the save problem. I have an event object which holds an array of pointers. I need to include the objects in this array only for particular users, which are the creators of the event. All this is to optimise my traffic.

eventsQuery.find({
success: function(events) {
var lastPage = true;
if (events.length > pageElements) {
events.pop();
lastPage = false;
}

  if (request.user != undefined) {
    if (request.user.get('userType') == 'agent') {
      for (var i = 0; i < events.length; i++) {

        if(events[i].get('eventCreator').id != request.user.id){
          events[i].set("respondents", []);
          events[i].set("accepted", []);
          events[i].set("denied", []);
        }
      }
    }
  }

  returnDict["events"] = events;
  returnDict["lastPage"] = lastPage;

  response.success(returnDict);
},
error: function(error){
  response.error("Something Went Wrong With Code: " + error.code + " And Message: " + error.message);
}

});

@emkman
Copy link

emkman commented May 19, 2017

Also would love this. The reason is in the encode function:

 if (forcePointers || !seen || seen.indexOf(seenEntry) > -1 || value.dirty() || _Object$keys(value._getServerData()).length < 1) {
      return value.toPointer();
}

If you call set after retrieving the object from the DB, it becomes dirty and you lose all the rest of the JSON. Very unfortunate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants