0

The below should query the parse.com backend and return either a matched user based on the text input or no match, no match meaning that their is no user with that name stored in the parse data browser.

The code runs, but seems to have no results or errors showing. I'm trying to work out why and understand how the code would need to change to correct this?

url is here http://kudosoo.com/findfriends.html

  <form class="Find Friend">

        <div class="error" style="display:none"></div>
        <input type="text" id="friendsearch" placeholder="Find Friend" class="input-field" required/> 
        <button type="submit" onclick = "finduser" >Find</button> 
</form>        

    <!-- Initialize the Parse object-->
    <script type="text/javascript">     
    Parse.initialize("xxxx", "xxxxx");


    function finduser() {

var findFriend = $('#friendsearch').val();
    var query = new Parse.Query(Parse.User);
    query.equalTo("username", findFriend); // find users that match
    query.find({
        success: function (friend) {
            if (findFriend.length) { console.log("Found match")} 

        },
        error: function (error) {
     if (findFriend.length === 0) { console.log("No match")} 

        }

    });
};

</script>

1 Answer 1

2

It sounds like you may have run into the issue with case-sensitivity.

The common solution we use is to create a before-save Cloud-Code module that creates a searchable version that we use .toLowerCase() on.

In your case that would be search_username, then when you're doing searches you use that field, using the input value which you also apply .toLowerCase() to before searching.

If you do a search here you'll find a bunch of other questions which go into more detail on how to implement it.

Here's one I answered a while back.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, sounds like this could be a little above my skill set...but will try and do some further research

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.