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

include() is not working properly #4390

Closed
janswist opened this issue Nov 26, 2017 · 1 comment
Closed

include() is not working properly #4390

janswist opened this issue Nov 26, 2017 · 1 comment

Comments

@janswist
Copy link

janswist commented Nov 26, 2017

I use Vue.js and have problem with include(). This is the Cloud Code function:
`Parse.Cloud.define('fetchMessages', function(req, res) {

var Messages = Parse.Object.extend("Messages");
var query = new Parse.Query(Messages);
query.limit(50);
query.descending('createdAt');
query.include("user");	
query.select("user.name");
query.withinKilometers("geo", req.params.geo, 5);
query.find({useMasterKey: true}).then(function(results){
	
	var arr = [];
	
	results.forEach(function(obj){			
		var curatedObj = obj.toJSON();
		delete curatedObj.geo;
		arr.push(curatedObj);
		console.log(curatedObj);
	})
	
	res.success(arr);
	
}, function(error) {
 
	console.log("error: " + error);
	response.error(error);
});	

});`

and when I use it with this client code:
Parse.Cloud.run('fetchMessages', { geo: new Parse.GeoPoint(self.location) }).then(function(results) { self.messages = results; });
I still get all the User data in Vue.js Root yet don't have any other keys downloaded in other objects. So it's like it's working for everything, but needed class.

I also tried adding additional select('user') just to make sure I tried other options. I suppose it could have something to do with User class itself since it's working for top-level object.

edit: to make things even more strange - logs on server say that it's working so no clue why it's still getting all the user data instead of selected ones:
Ran cloud function fetchMessages for user dDK4BJtFEL with: Input: {"geo":{"__type":"GeoPoint","latitude":51.0879378,"longitude":17.0536302}} Result: [{"user":{"createdAt":"2017-11-26T00:46:54.448Z","updatedAt":"2017-11-26T15:16:34.030Z","name":"Janek","objectId":"dDK4BJtFEL","__type":"Object","className":"_User"},"body":"nnn","createdAt":"2017-11-26T01:15:22.657Z","updatedAt":"2017-11-26T13:56:03.274Z","objectId":"rKEAhW2GD0"},{"body":"xx","createdAt":"2017-11-26T01:08:50.454Z","updatedAt":"2017-11-26T01:08:50.454Z","objectId":"HX8iyBO7I0"},{"body":"asd","createdAt":"2017-11-26T01:07:58.381Z","updatedAt":"2017-11-26T01:07:58.381Z","objectId":"mkQ0uWFoZA"},{"body":"Pierwsza dłuższa wiadomość tutaj. Zobaczymy ile można wcisnąć tekstu...","createdAt":"2017-11-25T23:54:00.369Z","updatedAt":"2017-11-25T23:54:00.369Z","objectId":"i2AFyhehi2"}]

edit2: When I try to delete curatedObj.user.authData server gives error invalid session token.
edit3: I deleted include('user') and still getting user data - it's getting really odd right now. The only thing that could do that is Parse.FacebookUtils but can't put my finger on that.

@janswist
Copy link
Author

Ok, seems that excessive data shows only if user is logged in so the authData is available. For others it shows exactly what I want.

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

1 participant