I have a signup routine I am running for users to create an account.
At that point, I want to submit a list of hashed numbers to parse.com, bring back any users that match on those, then create a relation between the user that just signed up and all the users that came back on the query... essentially to populate their friends list with all the people they know.
The code I have for this so far is as follows but I am going round in circles and would love a little clarity / explanation and help if anyone can spare the time :)
user.signUp(null, {
success: function(user) {
$scope.currentUser = user;
$scope.$apply();
alert('we are about to find your friends, this may take a moment and you will need to give us access to your address book etc message goes here later.')
// let's query the user table / class
var findFriendsQuery = new Parse.Query(Parse.User);
// let's see if we can find a friend with this mobile hash / these mobile hashes
findFriendsQuery.containedIn("mobilenumber",
["40a2933480522ae6e3fedf84ed4c1d22","4dfe947f398f65282af1bfe9d2e4ec3c"]);
findFriendsQuery.find({
// if we get a result / some results let's add a relation between the user that is just signing up and all the users that came back from the query
success: function(foundFriends) {
console.log(foundFriends);
var userObjectId = findFriendsQuery.get(email);
console.log(userObjectId);
}
});
$scope.$apply(function() { $location.url("/tab/friends"); });
},
error: function(user, error) {
alert("Unable to sign up: " + error.code + " " + error.message);
}
});
};