Parse & JS: Return only one object

This entry is part 24 of 25 in the series Parse & Javascript

If you want exactly one result, a more convenient alternative may be to use first instead of using find.

<!doctype html>
    <title>My Parse App</title>
    <script type='text/javascript' src=''></script>
    <script type='text/javascript' src=''></script>


    Parse.initialize('5d3sro43zBGj8AMYqWND5bFYMzAan7f5P5euZm7M', 'hlRZZqAylA7Fmah4Kk6ma8WK7QCT4cHrxjafnnkI');
    var MoviObject = Parse.Object.extend('MoviObject');
    var moviObject = new MoviObject();

    var query = new Parse.Query(MoviObject);

                success: function (moviObject) {
                    document.write('<h2>First Movie Found:</h2>');
                    var title = moviObject.get('titleName');
Try The Code

As there is only one object, moviObject will not be in array form and so to get the title, we need only to use moviObject.get().

Series Navigation<< Parse & JS: Retrieving comment using the parentId
Parse & JS: Queries on String >>

Leave a comment

Leave a Reply