Skip to content Skip to sidebar Skip to footer

Parse Query Not Restricting Results To Current User

Using parse.com and the JS SDK. Why wouldn't this query restrict the results to the current user only? I've used query.exists('ProfilePic'), Parse.User.current(); which i though

Solution 1:

You're not using query.exists() the way you think you are. Also, are you just trying to check to see if the current user has a profile image? Because you can just use the .has("key") method of objects, and a user is an object. If this is in cloud code, rather than client code, you may have to fetch the user first. If it is client code, you should already have an up to date user.

You should not be extending the user object. Not necessary at all. Use the Parse.User object type, so if you're querying for users, do var query = new Parse.Query( Parse.User );

So I think what you want is something more like:

var user = Parse.User.current();
if( user.has("ProfilePic") )
{
    //Do your stuff with the image
    var imageURL = user.get("ProfilePic").url();
    $('#Image01').attr('src', imageURL);
}
else
{
    alert("Error: User does not have a 'ProfilePic' set");
}

Post a Comment for "Parse Query Not Restricting Results To Current User"