0

I'm having a strange issue with Parse's Cloud Hosting platform. I have a route that displays info on all 'Providers' in my system. A Provider has a column that is a Pointer to a User object. This is a special Parse.User object.

My goal is to get all Providers and the User info that the provider points to. Seems simple, using the "include" method for the query.

The route code looks like this:

exports.index = function(req, res) {
  var providersQuery = new Parse.Query('Provider');
  providersQuery.include('user');
  providersQuery.find().then(function(providers) {
    console.log(providers); //for debugging
    res.render('providers/index', { providers: providers });
  });
};

Here's where things get weird. The above log statement shows all Providers with all the User data included:

[{ "address": "123 Main St.", "city": "Anytown", "zip": "77777",
"user":
  { "email": "john.smith@example.com", "firstName": "John", "lastName": "Smith", "objectId": "abcd123", "__type": "Object", "className": "_User" }
}]

Notice that the __type is "Object". However, in my view the User object data is truncated and only shows __type, className, and objectId fields:

//index.ejs
<%- JSON.stringify(providers) %>

Results in the following:

[{ "address": "123 Main St.", "city": "Anytown", "zip": "77777",
"user":
  { "objectId": "abcd123", "__type": "Pointer", "className": "_User" }
}]

All the info about the user is gone!! And the __type is now "Pointer". What the hell is going on?

Naeem Shaikh
  • 15,331
  • 6
  • 50
  • 88
Pop-A-Stash
  • 6,572
  • 5
  • 28
  • 54

1 Answers1

0

Apparently calling JSON.stringify on Parse object will return "included" objects back to their "Pointer" selves. I'm sure there is some good reason for this, but it's certainly inconvenient.

Pop-A-Stash
  • 6,572
  • 5
  • 28
  • 54