0

I think Parse has made some changes to its objects without providing a clear memo. I built my app with Node and most of the code rests on my server instead of Cloud Code. Recently I've noticed a number of errors on code that previously tested well. At first I thought it was security settings or Parse versions (I'm currently using the latest version, 1.6.7). I reverted back and updated and nothing has helped with this issue save for transporting my code to the cloud.

I look forward to real help/suggestions, I've already looked at the docs and I'm not finding what I need so please save your breath if you were to suggest that comment. Here is some example code illustrating the problem:

var Parse = require('parse/node');
Parse.initialize("app key", "JS key", "master key");

//for this example the app key and JS key may be backward but they are correct in the project.

var array = [{key: value}, {key1: value1}, {key2: value2}]

var Object = Parse.Object.extend("Table");
var objectQuery = new Parse.Query(Object);
objectQuery.first({
     success: function(result){
     var Id = result.get("user").id//this correctly provides me with the ID!

 _.each(array, function(n){
     _.mapObject(n, function(v, k){
        var Next = Parse.Object.extend("Info");
        var nextQuery = new Parse.Query(Next);
        nextQuery.equalTo("name", k);
        nextQuery.find({
            success: function(Row){
               var problem1 = _.map(Row, function(n){return _.find(n)})
               console.log(problem1);//this used to show me the JSON      
               key value pairs if it were an object or the array or 
               whatever, now I just get ['Info'] from the console.log.

               var problem2 = _.map(problem1, function(n){return 
               _.extend(n, {id: userId})});//this far ['Info'] 
               has proven completely impenetrable.  Granted I've used  
               underscore here but I've tried operations with basic 
               javascript functions like concat and any data within the  
               Parse Object is completely ignored. I'd like to do other  
               stuff from here but there is no point as I can't get 
               beyond 'undefined' should I try doing anything else with `the data.`

 }})})})}})

I'm desperate to move on from this and I believe it is something idiosyncratic. I've scoured Stack Overflow and other sources for days now trying to figure it out. Clearly I need some hand holding and I'm desperate to move on. Thanks.

rashadb
  • 2,515
  • 4
  • 32
  • 57
  • http://stackoverflow.com/questions/32000222/query-inside-parse-cloud-for-loop. Dupe maybe – Robert Rowntree Dec 15 '15 at 08:57
  • @RobertRowntree, thanks for the suggestion but I don't see the similarity: All of my queries are beginning and ending on the server, I'm not getting anything from or sending anything to the cloud. I do instantiate promises and other things but with the changes that have been implemented recently there's no point in talking about them as I can't do the most basic object manipulation on the server right now. When I started a year ago I had no problems manipulating Parse data structures on my server. All of this seems to be a very recent development. – rashadb Dec 15 '15 at 09:06
  • you have an 'underscore' loop with _each._mapObj... inside which you fire async ops to parse ... thats the similar process with the link – Robert Rowntree Dec 15 '15 at 14:36
  • @RobertRowntree, Do you know if Parse objects have always been this way or has something changed recently? Is there a way to take the data out of the Parse object so that it is raw JSON so I can avoid this sort of issue altogether? I'd prefer to take each object as JSON because dealing with it as a Parse object and my use case I don't even know where to begin solving this problem. – rashadb Dec 15 '15 at 21:18
  • https://www.parse.com/questions/cloud-code-multiple-queries-inside-loop something else that may help – Robert Rowntree Dec 15 '15 at 21:24
  • @RobertRowntree, Thanks but I'm still pretty lost. Like his solution, my problem has underscore. His solution includes a change to the way he calls response.success. I'm not operating in Cloud Code so I'm not calling response.success or res.send after what I showed you. I'm not an expert so I'm going to need a little more help; your guidance is far above my head right now in that I can't understand how it relates to my circumstance. I'm trying to manipulate a Parse object on the server, these other problems seem more concerned about the timing of calling response.success in the Cloud. – rashadb Dec 15 '15 at 21:40
  • When I looked at your code ,the fist thing that jumped out at me was that inside an underscore loop, you make async calls on parse ,each of which return the normal promise object.at the very least, you should be aware of the potential confused concurrency of all those pending promises – Robert Rowntree Dec 15 '15 at 21:56
  • @RobertRowntree I figured out my immediate coding challenge. The best I can tell is that you can not double loop a Parse.Object without promises. You also can not save Parse objects within a loop without promises. Somehow, I think this should be discussed in the docs somewhere. – rashadb Dec 16 '15 at 16:02

0 Answers0