in my Angular app I'm trying to display a set of results that come from three Classes. Data is stored on Parse.com.
I can do just fine with the Pointer relation type for one-to-one (associated scores are being returned).
Problem starts when I try to include data from the Location class into my final returned JSON.
Hopefully this is just a basic notation thing I'm missing. Thanks a lot!
Doctors
- String: firstname
- Pointer: score
- Relation: location
Scores
- Number: scoreOne
- Number: scoreTwo
Locations
- String: name
String: address
.controller('BrowseCtrl', function($scope) { // Get "Doctors" and associated "Scores" // via Pointer in Doctors Class named "score" var query = new Parse.Query("Doctors"); query.include("score"); query.find() .then(function(result){ var doctorsArray = new Array(); for(i in result){ var obj = result[i]; var doctorIds = obj.id; var docFirstname = obj.get("firstname"); var mainScore = obj.get("score").get("mainScore"); doctorsArray.push({ Scores:{ DocMainScore: mainScore }, firstname: docFirstname, }); } // Get Locations. // -can be more than one per Doctor // Class Doctors has a Relation column "location" pointing to Locations var locationsArray = new Array(); var locationRelation = obj.relation('location'); var locationQuery = locationRelation.query(); locationQuery.find({ success: function(locations) { for(j in locations){ var locObj = locations[j]; var locName = locObj.get("name"); console.log(locName); } } }) // send data to the view $scope.myData = doctorsArray; console.log(doctorsArray); }); })
What I am trying to do is get the data from Locations into the doctorsArray.